wrap Sorted < T > ( sortedData , comparer ? ) : { at : ( ( offset : number ) => undefined | T ) ; indexOf : ( ( sought : T , start ?: number , end ?: number ) => number ) ; insert : ( ( toInsert : T ) => { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }) ; insertionIndex : ( ( toInsert : T ) => number ) ; remove : ( ( toRemove : T ) => { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }) ; toArray : ( ( ) => T [] ) ; get data (): T [] ; get length (): number ; } Parameters sortedData : T [] comparer : Comparer < T > = defaultComparer Returns { at : ( ( offset : number ) => undefined | T ) ; indexOf : ( ( sought : T , start ?: number , end ?: number ) => number ) ; insert : ( ( toInsert : T ) => { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }) ; insertionIndex : ( ( toInsert : T ) => number ) ; remove : ( ( toRemove : T ) => { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }) ; toArray : ( ( ) => T [] ) ; get data (): T [] ; get length (): number ; } at : ( ( offset : number ) => undefined | T ) ( offset ) : undefined | T Returns undefined | T index Of : ( ( sought : T , start ?: number , end ?: number ) => number ) ( sought , start ? , end ? ) : number Parameters sought : T start : number = 0 end : number = store.length Returns number insert : ( ( toInsert : T ) => { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }) ( toInsert ) : { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }Returns { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; } insertion Index : ( ( toInsert : T ) => number ) ( toInsert ) : number Returns number remove : ( ( toRemove : T ) => { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }) ( toRemove ) : { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }Returns { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; } to Array : ( ( ) => T [] ) get data (): T [] get length (): number
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.