Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
test-forward.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# include <iostream>
33# include <htlist.H>
34# include <tpl_dynDlist.H>
35# include <tpl_dynSetTree.H>
36# include <tpl_dynMapTree.H>
37# include <tpl_arrayStack.H>
38
39using namespace std;
40using namespace Aleph;
41
42template <template <class> class Container, typename T>
43void test_container(int n)
44{
45 cout << "Probando con contenedor tipo lista" << endl;
47
48 cout << "append de R values\n";
49 for (int i = 0; i < n; ++i)
50 l.append(T(i));
51 cout << endl;
52
53 cout << "append de L values\n";
54 for (int i = 0; i < n; ++i)
55 {
56 T t = i;
57 l.append(t);
58 }
59 cout << endl;
60
61 cout << "insert de R values\n";
62 for (int i = 0; i < n; ++i)
63 l.insert(T(i));
64 cout << endl;
65
66 cout << "insert de L values\n";
67 for (int i = 0; i < n; ++i)
68 {
69 T t = i;
70 l.insert(t);
71 }
72 cout << endl;
73
74 for (typename Container<T>::Iterator it(l); it.has_curr(); it.next())
75 cout << it.get_curr() << " ";
76 cout << endl;
77}
78
79template <template <class, class> class Tree, typename T>
80void test_tree(int n)
81{
82 cout << "Probando con contenedor tipo arbol" << endl;
84
85 cout << "insert de R values\n";
86 for (int i = 0; i < n; ++i)
87 l.insert(T(i));
88 cout << endl;
89
90 cout << "insert de L values (no debe insertar en arbol)\n";
91 for (int i = 0; i < n; ++i)
92 {
93 T t = i;
94 l.insert(t);
95 }
96 cout << endl;
97
98 cout << "insert_dup de R values\n";
99 for (int i = 0; i < n; ++i)
100 l.insert_dup(T(i));
101 cout << endl;
102
103 cout << "insert_dup de L values\n";
104 for (int i = 0; i < n; ++i)
105 l.insert_dup(i);
106 cout << endl;
107
108 l.for_each([/* Lambda */] (const T & key) { cout << key << " "; });
109 cout << endl;
110}
111
112template <class Tree>
113void test_map_tree(int n)
114{
115 Tree (*create)(int) = [/* Lambda */] (int n) -> Tree
116 {
117 Tree t;
118 for (int i = 0; i < n; ++i)
119 t.insert(i, i + 2);
120 return t;
121 };
122
123 Tree tree = (*create)(n);
124}
125
126int main(int argc, char * argv[])
127{
128 int n = 1000;
129 if (argc > 1)
130 {
131 try { n = std::stoi(argv[1]); }
132 catch (...) { n = 1000; }
133 }
134
136
138
140
142
143 return 0;
144}
int main()
T & insert(const T &item)
Definition htlist.H:1220
T & append(const T &item)
Definition htlist.H:1271
Dynamic set backed by balanced binary search trees with automatic memory management.
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
Definition ah-dry.H:796
QuadTree - Hierarchical spatial index for 2D points.
Definition quadtree.H:126
Point * insert(Node *&r, const Point &p)
Recursive insert helper.
Definition quadtree.H:281
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
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
std::decay_t< typename HeadC::Item_Type > T
Definition ah-zip.H:105
@ Tree
Basic arc (in spanning tree).
STL namespace.
void test_tree(int n)
void test_container(int n)
void test_map_tree(int n)
Stack implementations backed by dynamic or fixed arrays.
Dynamic doubly linked list implementation.
Dynamic key-value map based on balanced binary search trees.
Dynamic set implementations based on balanced binary search trees.
DynList< int > l