class ARRAY_SORT{ELT}


Flattened version is here



Public


Features
insertion_sort(inout ar:ARRAY{ELT})
**** stable sort.
insertion_sort(inout ar:ARRAY{ELT},lt:ROUT{ELT,ELT}:BOOL)
**** stable sort.
insertion_sort_range(inout ar:ARRAY{ELT},l,u:INT)
insertion_sort_range(inout ar:ARRAY{ELT},l,u:INT, lt:ROUT{ELT,ELT}:BOOL)
**** sort by increasing order "<" with respect to `lt'.
lt_rev(a,b:ELT,lt:ROUT{ELT,ELT}:BOOL):BOOL
**** ">" with respect to lt(<).
quick_sort(inout ar:ARRAY{ELT})
**** Use quicksort to permute the elements of self so that it is sorted by increasing order "<" with respect to `elt_lt'. Self may be void.
quick_sort(inout ar:ARRAY{ELT}, lt:ROUT{ELT,ELT}:BOOL)
**** Use quicksort to permute the elements of self so that it is sorted by increasing order "<" with respect to `lt'. Self may be void.
quicksort_range(inout ar:ARRAY{ELT},l,u:INT)
quicksort_range(inout ar:ARRAY{ELT},l,u:INT,lt:ROUT{ELT,ELT}:BOOL)
sorted_insert(ar:ARRAY{ELT}, e:ELT):ARRAY{ELT}
**** assume ar is sorted by increasing order "<".
sorted_insert(ar:ARRAY{ELT}, e:ELT, lt:ROUT{ELT,ELT}:BOOL):ARRAY{ELT}
**** assume ar is sorted by increasing order "<"(with lt).
sorted_rev_insert(ar:ARRAY{ELT}, e:ELT):ARRAY{ELT}
**** assume ar is sorted by decreasing order ">".
sorted_rev_insert(ar:ARRAY{ELT}, e:ELT, lt:ROUT{ELT,ELT}:BOOL):ARRAY{ELT}


Private

const quicksort_limit:INT:=20;
**** When to stop the quicksort recursion and switch to insertion sort.

The Sather Home Page