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 This program is free software: you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <https://www.gnu.org/licenses/>.
26*/
27# include <iostream>
28# include <htlist.H>
29# include <tpl_dynDlist.H>
30# include <tpl_dynSetTree.H>
31# include <tpl_dynMapTree.H>
32# include <tpl_arrayStack.H>
33
34using namespace std;
35using namespace Aleph;
36
37template <template <class> class Container, typename T>
38void test_container(int n)
39{
40 cout << "Probando con contenedor tipo lista" << endl;
42
43 cout << "append de R values\n";
44 for (int i = 0; i < n; ++i)
45 l.append(T(i));
46 cout << endl;
47
48 cout << "append de L values\n";
49 for (int i = 0; i < n; ++i)
50 {
51 T t = i;
52 l.append(t);
53 }
54 cout << endl;
55
56 cout << "insert de R values\n";
57 for (int i = 0; i < n; ++i)
58 l.insert(T(i));
59 cout << endl;
60
61 cout << "insert de L values\n";
62 for (int i = 0; i < n; ++i)
63 {
64 T t = i;
65 l.insert(t);
66 }
67 cout << endl;
68
69 for (typename Container<T>::Iterator it(l); it.has_curr(); it.next())
70 cout << it.get_curr() << " ";
71 cout << endl;
72}
73
74template <template <class, class> class Tree, typename T>
75void test_tree(int n)
76{
77 cout << "Probando con contenedor tipo arbol" << endl;
79
80 cout << "insert de R values\n";
81 for (int i = 0; i < n; ++i)
82 l.insert(T(i));
83 cout << endl;
84
85 cout << "insert de L values (no debe insertar en arbol)\n";
86 for (int i = 0; i < n; ++i)
87 {
88 T t = i;
89 l.insert(t);
90 }
91 cout << endl;
92
93 cout << "insert_dup de R values\n";
94 for (int i = 0; i < n; ++i)
95 l.insert_dup(T(i));
96 cout << endl;
97
98 cout << "insert_dup de L values\n";
99 for (int i = 0; i < n; ++i)
100 l.insert_dup(i);
101 cout << endl;
102
103 l.for_each([/* Lambda */] (const T & key) { cout << key << " "; });
104 cout << endl;
105}
106
107template <class Tree>
108void test_map_tree(int n)
109{
110 Tree (*create)(int) = [/* Lambda */] (int n) -> Tree
111 {
112 Tree t;
113 for (int i = 0; i < n; ++i)
114 t.insert(i, i + 2);
115 return t;
116 };
117
118 Tree tree = (*create)(n);
119}
120
121int main(int argc, char * argv[])
122{
123 int n = 1000;
124 if (argc > 1)
125 {
126 try { n = std::stoi(argv[1]); }
127 catch (...) { n = 1000; }
128 }
129
131
133
135
137
138 return 0;
139}
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:779
QuadTree - Hierarchical spatial index for 2D points.
Definition quadtree.H:126
Point * insert(Node *&r, const Point &p)
Recursive insert helper.
Definition quadtree.H:237
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
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