Constructors
constructor
- new SortedArray<T>(
array?: T[],
comparator: (a: T, b: T) => number,
): SortedArray<T> Parameters
- array: T[] = []
- comparator: (a: T, b: T) => number
Properties
Readonly
comparator
comparator: (a: T, b: T) => number Readonly
raw
Accessors
length
- get length(): number
Returns number
Methods
clear
- clear(): void
Returns void
find
- find(item: T): null | T
Returns null | T
includes
- includes(item: T): boolean
Returns boolean
index
- index(item: T, closest?: boolean): number
Parameters
- item: T
- closest: boolean = false
Returns number
insert
- insert(item: T | T[]): number
Returns number
remove
- remove(item: T): void
Returns void
Array that adds elements in sorted order.
Comparator is always called like: comparator(itemFromSortedArray, yourItem)