Tools to work with sorted arrays, in a more efficient way.
DISCLAIMER: All types of utils only usable in a sorted array.
Static methods
View on GitHub
staticinlineaddSorted<T>(array:Array<T>, val:T, getVal:T ‑> Float):Void
Adds to a sorted array, using binary search.
Parameters:
array | Array to add to |
---|---|
val | Value to add |
getVal | Function that returns the value that needs to be sorted |
View on GitHub
staticbinarySearch<T>(array:Array<T>, val:Float, getVal:T ‑> Float):Int
Gets the index of a possible new element of an Array of T using an efficient algorithm.
Parameters:
array | Array of T to check in |
---|---|
getVal | Function that returns the position value of T |
Returns:
The index of the element
View on GitHub
staticinlineremoveSorted<T>(array:Array<T>, val:T, getVal:T ‑> Float):Void
Removes from a sorted array, using binary search.
Parameters:
array | Array to remove from |
---|---|
val | Value to remove |
getVal | Function that returns the value that needs to be sorted |