28# include <gsl/gsl_rng.h>
44template <
template <
class>
class C,
typename T>
47 for (
typename C<T>::Iterator it(c); it.has_curr(); it.next())
48 cout << it.get_curr() <<
" ";
65 cout <<
"** indexes(l1) = ";
68 cout <<
"(" << t.first <<
"," << t.second <<
")";
75 auto to_str = [&
l1] (
int i) -> std::string
77 return std::to_string(i);
89 for (
DynList<std::pair<int,int>>::Iterator it(
lz1); it.has_curr(); it.next())
90 cout << it.get_curr().first <<
"," << it.get_curr().second <<
endl;
93 cout <<
"Building random list" <<
endl;
95 for (
long i = 0; i < n; ++i)
99 <<
"building array copy of previous list" <<
endl;
108 <<
"Copying array to a tree" <<
endl;
116 <<
"Sorting array for ulterior fast searching";
120 <<
"traversing all the keys of tree and verifiying them with array"
124 return a(binary_search(a, i)) == i;
126 cout <<
"done!" <<
endl
128 <<
"Traversing all the keys of array and verifiying then with the tree"
132 return tree.search(i) != NULL;
134 cout <<
"done!" <<
endl
Functional programming utilities for Aleph-w containers.
High-level sorting functions for Aleph containers.
T & append()
Allocate a new entry to the end of array.
Dynamic doubly linked list with O(1) size and bidirectional access.
Dynamic singly linked list with functional programming support.
T & append(const T &item)
Dynamic set backed by balanced binary search trees with automatic memory management.
Key * append(const Key &key)
Aleph::DynList< T > take(const size_t n) const
Return a list with the first n elements seen in the container during its traversal.
bool all(Operation &operation) const
Check if all the elements of the container satisfy a condition.
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
Aleph::DynList< T > drop(const size_t n) const
Drop the first n elements seen in the container during its traversal.
Singly linked list implementations with head-tail access.
DynList< std::pair< typename Container1::Item_Type, typename Container2::Item_Type > > zip(const Container1 &a, const Container2 &b)
Zip two containers into a list of pairs.
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
std::pair< First, Second > pair
Alias to std::pair kept for backwards compatibility.
DynList< std::pair< size_t, typename Container::Key_Type > > indexes(const Container &c)
Return pairs of (index, key).
std::string to_str(const double d)
Convert double to a std::string with maximum round-trip precision.
Container< T > range(const T start, const T end, const T step=1)
Generate a range of values [start, end] with a given step.
void quicksort_op(C< T > &a, const Compare &cmp=Compare(), const size_t threshold=Quicksort_Threshold)
Optimized quicksort for containers using operator().
Aleph::DynList< T > keys() const
void print_seq(const C< T > &c)
Dynamic doubly linked list implementation.
Dynamic set implementations based on balanced binary search trees.
Unified hash table interface.