Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
testDynSlist.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 <iostream>
34# include <aleph.H>
35# include <tpl_dynSlist.H>
36
37# define Num_Items 10
38
39using namespace std;
40
41int main()
42{
43 DynSlist<int> list;
44 DynSlist<int*> list_ptr;
45
46 for (int i = 0; i < Num_Items; i++)
47 {
48 list.insert(i, i);
49 list_ptr.insert(i, &i);
50 }
51
53
55
56 itor_aux = itor;
57
58 for (/* nothing */; itor.has_curr(); itor.next())
59 cout << itor.get_curr() << " ";
60
61 cout << endl;
62
63 for (int i = Num_Items; i < 2*Num_Items; i++)
64 list.insert(i - Num_Items, i);
65
66 for (itor.reset_first(); itor.has_curr(); itor.next())
67 cout << itor.get_curr() << " ";
68
69 cout << endl;
70
71 for (int i = 2*Num_Items; i < 3*Num_Items; i++)
72 list.insert(0, i);
73
74 for (itor.reset_first(); itor.has_curr(); itor.next())
75 cout << itor.get_curr() << " ";
76
77 cout << endl;
78
79 for (int i = 3*Num_Items; i < 4*Num_Items; i++)
80 list.insert(list.size(), i);
81
82 for (int i = 0; i < list.size(); i++)
83 cout << list[i] << " ";
84
85 cout << endl;
86
87 for (int i = 0; i < list.size(); i++)
88 cout << list[list.size() - i - 1] << " ";
89
90 cout << endl;
91
92 list.remove(list.size() - 1);
93
94 list.remove(0);
95
96 for (itor.reset_first(); itor.has_curr(); itor.next())
97 cout << itor.get_curr() << " ";
98
99 cout << endl;
100
101}
Core header for the Aleph-w library.
Iterator specialized for DynSlist returning payload references.
Dynamic list of elements of type T implemented with a singly linked list of nodes.
size_t size() const noexcept
Return the number of stored elements.
void remove(const int pos)
Remove the node at position pos.
void insert(const int pos, const T &data)
Insert an element at position pos.
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
STL namespace.
#define Num_Items
int main()
Dynamic singly linked list.