60 C c = { 0, 1, 2, 3, 4, 5, 6, 7, 8 ,9 };
64 c.traverse([] (
auto i) { cout <<
" " << i;
return true; }); cout <<
endl;
66 a.traverse([] (
auto i) { cout <<
" " << i;
return true; }); cout <<
endl;
68 assert(c.all([] (
auto i) { return i >= 0; }));
69 assert(a.all([] (
auto i) { return i >= 0; }));
71 int vals[11];
int k = 0;
72 c.for_each([&
k, &
vals] (
int i) {
vals[
k++] = i; });
74 c.for_each([&c,
vals] (
int i) {
assert(c.nth_ne(i) ==
vals[i]); });
77 a.for_each([&
k, &
vals] (
int i) {
vals[
k++] = i; });
78 a.for_each([&a,
vals] (
int i) {
assert(a.nth_ne(i) ==
vals[i]); });
80 assert(c.find_ptr([] (
int i) { return i == 5; }));
81 assert(a.find_ptr([] (
int i) { return i == 5; }));
82 assert(
not c.find_ptr([] (
int i) { return i == 15; }));
83 assert(
not a.find_ptr([] (
int i) { return i == 15; }));
84 assert(
get<0>(c.find_item([] (
int i) { return i == 5; })));
86 get<1>(c.find_item([] (
int i) { return i == 5; })) == 5);
87 assert(
get<0>(a.find_item([] (
int i) { return i == 5; })));
89 get<1>(a.find_item([] (
int i) { return i == 5; })) == 5);
96 C c = { 0, 1, 2, 3, 4, 5, 6, 7, 8 ,9 };
98 c.traverse([] (
auto i) { cout <<
" " << i;
return true; }); cout <<
endl;
99 a.traverse([] (
auto i) { cout <<
" " << i;
return true; }); cout <<
endl;
102 c1.for_each([] (
int i) { cout <<
" " << i; }); cout <<
endl;
105 c2.for_each([] (
int i) { cout <<
" " << i; }); cout <<
endl;
107 vector<int> v = { 0, 1, 2, 3, 4, 5, 6, 7, 8 ,9 };
109 C
c3(v.begin(), v.end());
110 c3.for_each([] (
int i) { cout <<
" " << i; }); cout <<
endl;
112 const C
c4(v.begin(), v.end());
113 c4.for_each([] (
int i) { cout <<
" " << i; }); cout <<
endl;
119 C c = { 0, 1, 2, 3, 4, 5, 6, 7, 8 ,9 };
122 c.for_each([] (
int i) { cout <<
" " << i; }); cout <<
endl;
123 a.for_each([] (
int i) { cout <<
" " << i; }); cout <<
endl;
125 assert(c.all([&a] (
int i) { return a.exists([i] (int k)
126 { return k == i; }); }));
127 assert(a.all([&c] (
int i) { return c.exists([i] (int k)
128 { return k == i; }); }));
130 assert(c.exists([] (
int i) { return i == 9; }));
131 assert(a.exists([] (
int i) { return i == 9; }));
134 { return c.exists([i] (int k) { return i == k; }); }));
136 { return a.exists([i] (int k) { return i == k; }); }));
138 C
cm = c.maps([] (
int i) {
return 10*i; });
141 return c.exists([k] (int i) { return 10*i == k; });
144 const C
ccm = a.maps([] (
int i) {
return 10*i; });
147 return a.exists([k] (int i) { return 10*i == k; });
155 << c.template
foldl<int>(0, [] (
auto a,
auto i) {
return a + i; })
158 <<
ccm.template
foldl<int>(0, [] (
int a,
int i) { return a + i; })
160 <<
"S3 = " << c.
fold(0, [] (
auto a,
auto i) {
return a + i; })
162 <<
"S4 = " << a.fold(0, [] (
auto a,
auto i) { return a + i; })
167 sort(c.filter([] (
int i) { return i < 6; }))));
169 sort(a.filter([] (
int i) { return i < 6; }))));
171 c.pfilter([] (
int i) {
return i < 6; }).
for_each([] (
auto p)
176 a.pfilter([] (
int i) {
return i < 6; }).
for_each([] (
auto p)
183 auto cmp_tup = [] (std::tuple<size_t,size_t>
t1, std::tuple<size_t,size_t>
t2)
188 auto l1 =
sort(c.pfilter([] (
int i) { return i < 6; }),
cmp_tup);
189 auto l2 =
sort(a.pfilter([] (
int i) { return i < 6; }),
cmp_tup);
203 auto eq_tup = [] (std::tuple<size_t,size_t>
t1, std::tuple<size_t,size_t>
t2)
209 auto p = c.partition([] (
int i) {
return i < 6; });
212 p = a.partition([] (
int i) {
return i < 6; });
216 auto t = c.tpartition([] (
int i) {
return i < 6; });
219 t = a.tpartition([] (
int i) {
return i < 6; });
226 c.take(3).for_each([] (
auto i) { cout << i <<
" "; });
228 a.take(3).for_each([] (
auto i) { cout << i <<
" "; });
235 c.take(3).for_each([] (
auto i) { cout << i <<
" "; });
237 cc.take(3).for_each([] (
auto i) { cout << i <<
" "; });
244 cout <<
"All test were passed!" <<
endl
252 cout <<
"Testing for " <<
typeid(C).name() <<
endl
259 cout <<
"Ended tests for " <<
typeid(C).name() <<
endl
High-level sorting functions for Aleph containers.
Dynamic doubly linked list with O(1) size and bidirectional access.
Doubly-linked list (defined in tpl_dynList.H).
T fold(const T &init, Operation &operation) const
Simplified version of foldl() where the folded type is the same type of elements stored in the contai...
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
bool eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Check equality of two containers using a predicate.
and
Check uniqueness with explicit hash + equality functors.
DynArray< T > sort(const DynArray< T > &a, Cmp &&cmp=Cmp())
Returns a sorted copy of a DynArray.
Operation for_each(Itor beg, const Itor &end, Operation op)
Apply an operation to each element in a range.
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
std::ostream & join(const C &c, const std::string &sep, std::ostream &out)
Join elements of an Aleph-style container into a stream.
FooMap m(5, fst_unit_pair_hash, snd_unit_pair_hash)
Fixed-capacity binary heap and heapsort algorithms.
Circular queue implementations backed by arrays.
Array-based dynamic binary heap.
Lazy and scalable dynamic array implementation.
Dynamic binary heap with node-based storage.
Dynamic doubly linked list implementation.
Dynamic stack implementation based on linked lists.
Dynamic set implementations based on hash tables.
Dynamic set implementations based on balanced binary search trees.
Open addressing hash table with double hashing.
Open addressing hash table with linear probing.
Random access queue (bag) with O(1) random pop.