22 static inline bool leq (T& a, T&
b) {
return a <=
b; }
25template <
class T,
class LEQ>
28 if (end -
start <= 1)
return;
29 if (end -
start == 2) {
51template <
class T,
class LEQ>
68template <
class T,
class U,
class LEQ>
72 if (end -
start <= 1)
return;
73 if (end -
start == 2) {
89 if (LEQ::leq (a[i], a[
j])) {
102 for (i=
start; i <
j; i++) {
108template <
class T,
class U,
class LEQ>
111 ASSERT (
N (a) ==
N (
b),
"arrays of the same length expected");
117template <
class T,
class LEQ>
121 for (
int i= 0; i <
N (a); i++)
136 ASSERT (
N (a) ==
N (
b),
"arrays of the same length expected");
138 for (
int i= 0; i <
N (a); i++)
int N(array< T > a)
Get the length of the array.
#define ASSERT(cond, msg)
Macro used to assert that a condition is true, and throw an exception with an error message if the co...
The list class represents a linked list.
array< T > permute(array< T > &a, array< int > b)
static void merge_sort_sub(array< T > &a, int start, int end, array< T > &merge_buf)
void merge_sort_leq(array< T > &a)
array< int > merge_sort_leq_permutation(array< T > &a)
void merge_sort(array< T > &a)
static bool leq(T &a, T &b)