Allows array-like indexing.
Returns an iterator for the array.
Adds a new value to the sorted array.
Complexity: O(log(n)) for binary search + O(n) for insertion
The value to add.
The index at which the value was inserted.
Adds multiple values to the sorted array.
Complexity: O(M * log(n)) for finding insertion points + O(n) for rebuilding the array, where M is the number of items to add.
The values to add.
Array of indices, in ascending order, where the values were inserted.
Clears the array, removing all elements.
Complexity: O(1)
Creates a new ISortedArray
by filtering the elements of this array using the specified predicate.
Complexity: O(n) for filtering. No sort comparison are performed since it's assumed all elements will be in the same relative order.
A new ISortedArray
containing the elements that match the predicate.
Finds the first index of an element that matches using the specified predicate.
Complexity: O(n) for search
The index of the first matching element, which will be -1
if not found.
Finds all indices of elements that match using the specified predicate.
Complexity: O(n) for search
The indices of the matching elements, in ascending order, which will be empty if no matches are found.
Finds the last index of an element that matches using the specified predicate.
Complexity: O(n) for search
The index of the last matching element, which will be -1
if not found.
Finds the index of the first element that matches the provided value.
Complexity: O(log(n))
The value to find.
The index of the first matching element, or -1
if not found.
Gets the item at the specified index.
Complexity: O(1)
The index to access.
The item at the specified index.
Finds the index of the last element that matches the provided value.
Complexity: O(log(n))
The value to find.
The index of the last matching element, or -1
if not found.
Removes all elements that match the provided value.
Complexity: O(log(n)) for search + O(n) for removal
The value to remove.
Array of former indices of the removed elements (in reverse order).
Removes the element at the specified index.
Complexity: O(n) for removal
The index of the element to remove.
The index of the removed element, or -1
if invalid (non-integer) or out of bounds.
Removes the elements at the specified indices.
Complexity: O(n) for rebuilding the array
The indices of the elements to remove.
Array of former indices of the removed elements (in reverse order).
Removes the first element that matches the provided value.
Complexity: O(log(n)) for search + O(n) for removal
The value to remove.
The former index of the removed element, or -1
if not found.
Removes the last element that matches the provided value.
Complexity: O(log(n)) for search + O(n) for removal
The value to remove.
The former index of the removed element, or -1
if not found.
Removes multiple values from the sorted array.
If specified values are duplicated in the array, all occurrences are removed.
Complexity: O(M * log(n)) for finding values + O(n) for rebuilding the array, where M is the number of items to remove.
The values to remove.
Array of indices, in descending order, of the items that were removed.
SortedArray is a generic class that maintains a sorted array of items.