Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
testSlink.C
Go to the documentation of this file.
1
2/* Aleph-w
3
4 / \ | | ___ _ __ | |__ __ __
5 / _ \ | |/ _ \ '_ \| '_ \ ____\ \ /\ / / Data structures & Algorithms
6 / ___ \| | __/ |_) | | | |_____\ V V / version 1.9c
7 /_/ \_\_|\___| .__/|_| |_| \_/\_/ https://github.com/lrleon/Aleph-w
8 |_|
9
10 This file is part of Aleph-w library
11
12 Copyright (c) 2002-2018 Leandro Rabindranath Leon
13
14 Permission is hereby granted, free of charge, to any person obtaining a copy
15 of this software and associated documentation files (the "Software"), to deal
16 in the Software without restriction, including without limitation the rights
17 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 copies of the Software, and to permit persons to whom the Software is
19 furnished to do so, subject to the following conditions:
20
21 The above copyright notice and this permission notice shall be included in all
22 copies or substantial portions of the Software.
23
24 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 SOFTWARE.
31*/
32
33# include <aleph.H>
34# include <slink.H>
35
36# define NumItems 10
37
38struct Record1 : public Slink
39{
40 unsigned n;
41
42 Record1* get_next() { return static_cast<Record1*>(Slink::get_next()); }
43};
44
45struct Record2
46{
47 unsigned n;
48
50
52};
53# include <iostream>
54
55
56void* foo();
57
58int main()
59{
60 {
61 Record1 head;
62 unsigned i;
63 Record1 *node;
64 Record1 *aux;
65
66 for (i = 0; i < NumItems; i++)
67 {
68 node = new Record1;
69
70 node->n = i;
71 head.insert_next(node);
72 }
73
74 for (node = head.get_next(); node not_eq &head; node = node->get_next())
75 {
76 printf("%u ", node->n);
77 }
78
79 while (not head.is_empty())
80 {
81 aux = static_cast<Record1*>(head.remove_next());
82 delete aux;
83 }
84 }
85
86 {
87 Slink head;
88 unsigned i;
89 Record2 *node;
90 Slink *link;
91
92 for (i = 0; i < NumItems; i++)
93 {
94 node = new Record2;
95
96 node->n = i;
97 head.insert_next(&node->link);
98 }
99
100 for (link = head.get_next(); link not_eq &head; link = link->get_next())
101 {
102 node = Record2::slink_to_type(link);
103 printf("%u ", node->n);
104 }
105
106 while (not head.is_empty())
107 {
108 node = Record2::slink_to_type(head.remove_next());
109 delete node;
110 }
111 }
112
113 printf("Ended\n");
114}
Core header for the Aleph-w library.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
unsigned n
Definition testSlink.C:40
Record1 * get_next()
Definition testSlink.C:42
Slink link
Definition testSlink.C:49
unsigned n
Definition testSlink.C:47
static Record2 * slink_to_type(Slink *link)
Definition testSlink.C:51