Vectors
Utility functions for vectors.
Interface
find_upper_bound
Searches a sorted vec
and returns the first index that contains a value greater or equal to element
. If no such index exists (i.e. all values in the vector are strictly less than element
), and the vector length is returned.
Time complexity O(log n).
@param vec: The vector to be searched.
@param element: We check if there is a value higher than it in the vector.
@return u64. The index of the member that is larger than
element
. The length is returned if no member is found.
lt
Checks if a
is smaller than b
. E.g. x"123" < x"456".
@param a: The first operand.
@param b: The second operand..
@return bool. If
a
is smaller thanb
.
Aborts
a
andb
have different lengths.
gt
Checks if a
is larger than b
. E.g. x"123" < x"456".
@param a: The first operand.
@param b: The second operand..
@return bool. If
a
is larger thanb
.
Aborts
a
andb
have different lengths.
lte
Checks if a
is smaller or equal to b
. E.g. x"123" =< x"456".
@param a: The first operand.
@param b: The second operand..
@return bool. If
a
is smaller or equal tob
.
Aborts
a
andb
have different lengths.
gte
Checks if a
is larger or equal to b
. E.g. x"123" =< x"456".
@param a: The first operand.
@param b: The second operand..
@return bool. If
a
is larger or equal tob
.
Aborts
a
andb
have different lengths.
ascending_insertion_sort
Sorts a a
in ascending order. E.g. [342] => [234].
@param a: The vector to sort.
@return vector. Sorted
a
.
Aborts
a
andb
have different lengths.
descending_insertion_sort
Sorts a a
in descending order. E.g. [342] => [432].
@param a: The vector to sort.
@return vector. Sorted
a
.
Aborts
a
andb
have different lengths.
quick_sort
Sorts a values
. E.g. [342] => [234].
This function mutates the original vector.
@param values: The vector to sort.
@param left: The smaller side of the pivot. Pass 0.
@param right: The larger side of the pivot. Pass
vector::length - 1
.
Last updated