28# include <gsl/gsl_rng.h>
42template <
template <
typename T>
class List,
47 for (
int i = 0; i < n; ++i)
53template <
template <
typename T>
class List,
57 T value = numeric_limits<T>::min();
58 return list.all([&value] (
const T & item)
60 bool ret = value <= item;
66template <
template <
typename T>
class List,
71 for (
int i = 0; i < n; ++i)
77template <
template <
typename T>
class List,
81 T value = numeric_limits<T>::min();
82 return list.all([&value] (
T * ptr)
84 bool ret = value <= *ptr;
90template <
template <
typename T>
class List,
typename T>
93 list.for_each([] (
T * ptr)
101 unsigned long n = 1000;
110 cerr <<
"Invalid n: must be a non-negative integer <= "
117 unsigned int t = std::time(
NULL);
129 t =
static_cast<unsigned int>(
parsed_t);
132 cout <<
argv[0] <<
" " << n <<
" " << t <<
endl;
138 cout <<
"Testing quicksort on single lists" <<
endl
139 <<
"Building list ... " <<
endl;
141 cout <<
"sorting it ..." <<
endl;
143 cout <<
"done! " <<
endl
144 <<
"Verifying ... " <<
endl;
147 cout <<
"done!" <<
endl
152 cout <<
"Testing quicksort on single lists of pointers" <<
endl
153 <<
"Building list ... " <<
endl;
155 cout <<
"sorting it ..." <<
endl;
160 cout <<
"done! " <<
endl
161 <<
"Verifying ... " <<
endl;
164 cout <<
"done!" <<
endl
170 cout <<
"Testing mergesort on single lists" <<
endl
171 <<
"Building list ... " <<
endl;
173 cout <<
"sorting it ..." <<
endl;
175 cout <<
"done! " <<
endl
176 <<
"Verifying ... " <<
endl;
179 cout <<
"done!" <<
endl
184 cout <<
"Testing mergesort on single lists of pointers" <<
endl
185 <<
"Building list ... " <<
endl;
187 cout <<
"sorting it ..." <<
endl;
192 cout <<
"done! " <<
endl
193 <<
"Verifying ... " <<
endl;
196 cout <<
"done!" <<
endl
202 cout <<
"Testing default sort method on single lists" <<
endl
203 <<
"Building list ... " <<
endl;
205 cout <<
"sorting it ..." <<
endl;
207 cout <<
"done! " <<
endl
208 <<
"Verifying ... " <<
endl;
211 cout <<
"done!" <<
endl
High-level sorting functions for Aleph containers.
void append(Dlink *node) noexcept
Insert node before this.
Node belonging to a double circular linked list with header node.
Dynamic singly linked list with functional programming support.
size_t length() const noexcept
Count the number of elements of a container.
void mergesort(T *a, const long l, const long r, std::vector< T > &buf, Compare cmp)
Sort an array using merge sort with a reusable buffer.
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
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.
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.