36# include <gsl/gsl_rng.h>
44# define NumItems 10000
56 cout <<
"Testing simple insertions and searches ...." <<
endl;
58 for (
unsigned long i = 0; i < n; i++)
90 for (
size_t i = 0; i < n; i++)
102 cout <<
"testing empty() method ...." <<
endl;
110 cout <<
"Reinserting keys ...." <<
endl;
111 for (
size_t i = 0; i < n; ++i)
120 cout <<
"Done!" <<
endl;
123 cout <<
"Testing iterator and map ...." <<
endl;
126 ( [] (
const unsigned long &
k) ->
unsigned long
134 cout <<
"done!" <<
endl;
138 cout <<
"testing lvalue copy constructor ...." <<
endl;
145 cout <<
"testing lvalue assigment...." <<
endl;
147 for (
size_t i = 0; i < n/2; ++i)
161 cout <<
"Testing rvalue constructor ...." <<
endl;
164 cout <<
"done!" <<
endl
166 <<
"Testing rvalue assign = .... " <<
endl
169 cout <<
"done!" <<
endl
176 cout <<
"done" <<
endl
177 <<
"Reinserting ...." <<
endl;
182 for (
size_t i = 0; i < n; ++i)
186 cout <<
"Searching inserted keys ...." <<
endl;
187 for (
size_t i = 0; i < n; ++i)
201 cout <<
"Testing keys() in set ...." <<
endl
207 return table.
has(key);
213 <<
"Testing filter of keys multiples of 13" <<
endl;
216 filter(table, [](
const unsigned long & key)
218 return key % 13 == 0;
221 table.
filter( [] (
const unsigned long & key)
223 return key % 13 == 0;
240 cout <<
"Testing simple insertions and searches ...." <<
endl;
241 for (
unsigned long i = 0; i < n; i++)
261 for (
size_t i = 0; i < n; i++)
262 if (table.search(
keys(i)) !=
nullptr)
264 table.remove(
keys(i));
269 assert(table.size() == 0);
273 cout <<
"testing empty() method ...." <<
endl;
278 assert(table.size() == 0);
281 cout <<
"Reinserting keys ...." <<
endl;
282 for (
size_t i = 0; i < n; ++i)
283 if (table.insert(
keys(i), i) ==
nullptr)
291 cout <<
"Done!" <<
endl
293 <<
"Testing for_each and a battery of other tests ...." <<
endl;
295 assert(table.all([&table] (
const std::pair<const unsigned long, long> & p)
297 auto * ptr = table.search(p.first);
298 assert(ptr != nullptr);
299 assert(table.get_data(p.first) == ptr->second);
300 return table.has(p.first);
304 cout <<
"done!" <<
endl
306 <<
"testing keys() method and other tests ...." <<
endl;
309 {
return table.has(
k); }));
311 cout <<
"done!" <<
endl
313 <<
"Testing items() method and other stuff ...." <<
endl;
316 (std::pair<unsigned long, long> p)
317 {
return table.find(p.first) == p.second; } ));
318 cout <<
"done!" <<
endl
327 if (
argv[1][0] ==
'-')
342 unsigned int t = (
unsigned int)
time(
nullptr);
345 if (
argv[2][0] ==
'-')
358 t =
static_cast<unsigned int>(
parsed_t);
361 cout <<
argv[0] <<
" " << n <<
" " << t <<
endl;
Functional programming utilities for Aleph-w containers.
High-level sorting functions for Aleph containers.
Iterator on the items of list.
Doubly-linked list (defined in tpl_dynList.H).
Generic key-value map implemented on top of a binary search tree.
bool has(const Key &key) const noexcept
Pair * insert(const Key &key, const Data &data)
Insert a key-value pair.
Dynamic set implemented using randomized treap binary search trees of type Treap<Key>.
Dynamic set backed by balanced binary search trees with automatic memory management.
const size_t & size() const
Returns the cardinality of the set.
Key * insert(const Key &key)
Inserts a key into the dynamic set.
bool has(const Key &key) const
size_t remove(const Key &key)
Removes a key from the dynamic set.
Key * search(const Key &key) const
Find an element in the set.
void empty()
remove all elements from the set
bool has_curr() const noexcept
bool equal_to(const Container &r) const noexcept
Test if elements of this are exactly contained in another container.
Aleph::DynList< T > filter(Operation &operation) const
Filter the elements of a container according to a matching criterion.
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().
Container2< typename Container1::Item_Type > filter(Container1 &container, Operation &operation)
Filter elements that satisfy operation.
bool all(Container &container, Operation &operation)
Return true if all elements satisfy a predicate.
and
Check uniqueness with explicit hash + equality functors.
bool contains(const std::string_view &str, const std::string_view &substr)
Check if substr appears inside str.
Operation for_each(Itor beg, const Itor &end, Operation op)
Apply an operation to each element in a range.
bool binary_search(Itor beg, Itor end, const T &value)
Binary search for a value.
Aleph::DynList< T > keys() const
Aleph::DynList< T > items() const
Return a list of all the elements of a container sorted by traversal order.
DynSetTree< unsigned long > create_table(const DynSetTree< unsigned long > &other)
void test_DynSet(size_t n)
unsigned long insert_n_random_items_in_set(DynSetTree< unsigned long > &table, DynArray< unsigned long > &keys, unsigned long n)
unsigned long insert_n_random_items_in_map(DynMapTree< unsigned long, long > &table, DynArray< unsigned long > &keys, unsigned long n)
void test_DynMap(size_t n)
Dynamic key-value map based on balanced binary search trees.
Comprehensive sorting algorithms and search utilities for Aleph-w.