33# include <gsl/gsl_rng.h>
47template <
template <
typename T>
class List,
52 for (
int i = 0; i < n; ++i)
58template <
template <
typename T>
class List,
62 T value = numeric_limits<T>::min();
63 return list.all([&
value] (
const T & item)
71template <
template <
typename T>
class List,
76 for (
int i = 0; i < n; ++i)
82template <
template <
typename T>
class List,
86 T value = numeric_limits<T>::min();
87 return list.all([&
value] (
T * ptr)
95template <
template <
typename T>
class List,
typename T>
98 list.for_each([] (
T * ptr)
106 unsigned long n = 1000;
115 cerr <<
"Invalid n: must be a non-negative integer <= "
122 unsigned int t = std::time(
NULL);
134 t =
static_cast<unsigned int>(
parsed_t);
137 cout <<
argv[0] <<
" " << n <<
" " << t <<
endl;
143 cout <<
"Testing quicksort on single lists" <<
endl
144 <<
"Building list ... " <<
endl;
146 cout <<
"sorting it ..." <<
endl;
148 cout <<
"done! " <<
endl
149 <<
"Verifying ... " <<
endl;
152 cout <<
"done!" <<
endl
157 cout <<
"Testing quicksort on single lists of pointers" <<
endl
158 <<
"Building list ... " <<
endl;
160 cout <<
"sorting it ..." <<
endl;
165 cout <<
"done! " <<
endl
166 <<
"Verifying ... " <<
endl;
169 cout <<
"done!" <<
endl
175 cout <<
"Testing mergesort on single lists" <<
endl
176 <<
"Building list ... " <<
endl;
178 cout <<
"sorting it ..." <<
endl;
180 cout <<
"done! " <<
endl
181 <<
"Verifying ... " <<
endl;
184 cout <<
"done!" <<
endl
189 cout <<
"Testing mergesort on single lists of pointers" <<
endl
190 <<
"Building list ... " <<
endl;
192 cout <<
"sorting it ..." <<
endl;
197 cout <<
"done! " <<
endl
198 <<
"Verifying ... " <<
endl;
201 cout <<
"done!" <<
endl
207 cout <<
"Testing default sort method on single lists" <<
endl
208 <<
"Building list ... " <<
endl;
210 cout <<
"sorting it ..." <<
endl;
212 cout <<
"done! " <<
endl
213 <<
"Verifying ... " <<
endl;
216 cout <<
"done!" <<
endl
High-level sorting functions for Aleph containers.
size_t size_t int32_t value
void append(Dlink *node) noexcept
Insert node before this.
Node belonging to a double circular linked list with header node.
Doubly-linked list (defined in tpl_dynList.H).
size_t length() const noexcept
Count the number of elements of a container.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
std::decay_t< typename HeadC::Item_Type > T
DynArray< T > sort(const DynArray< T > &a, Cmp &&cmp=Cmp())
Returns a sorted copy of a DynArray.
void quicksort(T *a, const long l, const long r, const Compare &cmp=Compare())
Sort an array using iterative quicksort with optimizations.
void mergesort(T *a, const long l, const long r, Array< T > &buf, Compare cmp)
Sort an array using merge sort with a reusable buffer.
List< T > build_int_list(int n)
List< T * > build_ptr_list(int n)
void free_ptr_list(List< T * > &list)
bool verify_sort(const List< T > &list)
Comprehensive sorting algorithms and search utilities for Aleph-w.