Returns an immutable wrapper around a sorted array.
Use wrapUnsorted if not yet sorted.
Functions that change contents return a new wrapped instance.
letw = wrapSorted([ 1, 2, 10 ]); w.indexOf(1); // 0 w = w.insert(9); // Inserts 9, returning a new wrapper w = w.remove(9); // Removes 9, returning a new wrapper
You can access the underyling sorted array with the data property.
It's important this is not modified since the wrapper assumes its immutable
and stays sorted. Use toArray() to get a copy of the array which can be
changed.
// A few basic array-like features supported w.length; // Get length of array w.at(0); // Get item at index 0 w.data; // Get underlying array w.toArray(); // Get a copy of the underyling array
Returns an immutable wrapper around a sorted array. Use wrapUnsorted if not yet sorted.
Functions that change contents return a new wrapped instance.
You can access the underyling sorted array with the
data
property. It's important this is not modified since the wrapper assumes its immutable and stays sorted. UsetoArray()
to get a copy of the array which can be changed.