5.2. Boost package for the builtin sort

The SORT_BOOST module provides the qsort macro that uniformly sorts built-in arrays, dynamic arrays, and C++ handled vectors using the same syntax. It automatically wraps handled types in temp_array as needed.

All functions and symbols are in “sort_boost” module, use require to get access to it.

require daslib/sort_boost

5.2.1. Call macros

qmake_heap

Implements qmake_heap(value, block) for arrays and handled vectors.

qnth_element

Implements qnth_element(value, n, block) for arrays and handled vectors. Same dispatch shape as qpartial_sort.

qpush_heap

Implements qpush_heap(value, block) for arrays and handled vectors. Pre: new element already at end.

qsort

Implements qsort macro. It’s qsort(value,block). For the regular array<> or dim it’s replaced with sort(value,block). For the handled types like das`vector its replaced with sort(temp_array(value),block).

qpartial_sort

Implements qpartial_sort(value, n, block) — dispatches to partial_sort for array sources or partial_sort(temp_array(value), …) for handled vector types.

qpop_heap

Implements qpop_heap(value, block) for arrays and handled vectors. Moves max to end; caller drops it.

5.2.2. Partial sorting

5.2.2.1. nth_element

nth_element(a: array<auto(TT)>|array<auto(TT)>#; n: int): auto

def nth_element (var a: array<auto(TT)>|array<auto(TT)>#; n: int) : auto

Arguments:
  • a : option<array<auto(TT)>| array<auto(TT)>#>

  • n : int

nth_element(a: array<auto(TT)>|array<auto(TT)>#; n: int; cmp: block<(x:TT;y:TT):bool>): auto

5.2.2.2. partial_sort

partial_sort(a: array<auto(TT)>|array<auto(TT)>#; n: int): auto

def partial_sort (var a: array<auto(TT)>|array<auto(TT)>#; n: int) : auto

Arguments:
  • a : option<array<auto(TT)>| array<auto(TT)>#>

  • n : int

partial_sort(a: array<auto(TT)>|array<auto(TT)>#; n: int; cmp: block<(x:TT;y:TT):bool>): auto

5.2.3. Heap operations

5.2.3.1. make_heap

make_heap(a: array<auto(TT)>|array<auto(TT)>#): auto

def make_heap (var a: array<auto(TT)>|array<auto(TT)>#) : auto

Arguments:
  • a : option<array<auto(TT)>| array<auto(TT)>#>

make_heap(a: array<auto(TT)>|array<auto(TT)>#; cmp: block<(x:TT;y:TT):bool>): auto

5.2.3.2. pop_heap

pop_heap(a: array<auto(TT)>|array<auto(TT)>#): auto

def pop_heap (var a: array<auto(TT)>|array<auto(TT)>#) : auto

Arguments:
  • a : option<array<auto(TT)>| array<auto(TT)>#>

pop_heap(a: array<auto(TT)>|array<auto(TT)>#; cmp: block<(x:TT;y:TT):bool>): auto

5.2.3.3. push_heap

push_heap(a: array<auto(TT)>|array<auto(TT)>#): auto

def push_heap (var a: array<auto(TT)>|array<auto(TT)>#) : auto

Arguments:
  • a : option<array<auto(TT)>| array<auto(TT)>#>

push_heap(a: array<auto(TT)>|array<auto(TT)>#; cmp: block<(x:TT;y:TT):bool>): auto