Module indxvec::merge[][src]

Functions

Binary search of a sorted list (in ascending order). Returns the index of the first item that is greater than val. When none are greater, returns s.len() (invalid index but logical). Example use: looking up cummulative probability density functions.

Merges two ascending sorted generic vectors, by classical selection and copying of their head items into the result. Consider using merge_indexed instead, especially for non-primitive end types T.

Merges two ascending sort indices. Data is not shuffled at all, v2 is just concatenated onto v1 in one go and both remain in their original order. Returns the concatenated vector and a new valid sort index into it.

Finds minimum, minimum’s first index, maximum, maximum’s first index of &[T]

Fast ranking of many T items, with only n*(log(n)+1) complexity. Ranking is done by inverting the sort index.
Sort index is in sorted order, giving data positions. Ranking is in data order, giving sorted order positions. Thus sort index and ranks are in an inverse relationship. They are easily converted by .invindex() (for: invert index).

Reverse a generic slice by reverse iteration. Creates a new Vec (is immutable). Its naive use for descending sort etc. is to be avoided for efficiency reasons. Included here just for convenience.

A wrapper for mergesort, to obtain the sort index of the (whole) input vector. Simpler than sortm.

Immutable sort. Returns new sorted vector (ascending or descending). Is a wrapper for mergesort. Passes the boolean flag ‘ascending’ onto ‘unindex’. Mergesort by itself always produces only an ascending index.