Module utils/sorted-array-utils
Functions
SortedDifference
SortedDifference<T>( array: readonly T [] , values: readonly T [] , compare: ( left: T , right: T ) => number ) : T []
Type parameters
Parameters
array: readonly T []
values: readonly T []
compare: ( left: T , right: T ) => number
( left: T , right: T ) : number
Parameters
Returns number
Returns T []
SortedPartition
SortedPartition<T>( array: readonly T [] , values: readonly T [] , compare: ( left: T , right: T ) => number ) : [ T [] , T [] ]
Type parameters
Parameters
array: readonly T []
values: readonly T []
compare: ( left: T , right: T ) => number
( left: T , right: T ) : number
Parameters
Returns number
Returns [ T [] , T [] ]
binarySearch
binarySearch<T>( array: readonly T [] , item: T , comparator: ( a: T , b: T ) => number ) : number
Type parameters
Parameters
array: readonly T []
item: T
comparator: ( a: T , b: T ) => number
Parameters
Returns number
Returns number
sortedFind
sortedFind<T>( array: readonly T [] , el: T , compare: ( left: T , right: T ) => number ) : T | undefined
Type parameters
Parameters
array: readonly T []
el: T
compare: ( left: T , right: T ) => number
( left: T , right: T ) : number
Parameters
Returns number
Returns T | undefined
sortedInsert
sortedInsert<T>( array: T [] , value: T , compare: ( left: T , right: T ) => number ) : number
Type parameters
Parameters
array: T []
value: T
compare: ( left: T , right: T ) => number
( left: T , right: T ) : number
Parameters
Returns number
Returns number
sortedInsertAll
sortedInsertAll<T>( array: T [] , values: T [] , compare: ( left: T , right: T ) => number , skipDuplicates?: boolean ) : number
Type parameters
Parameters
array: T []
values: T []
compare: ( left: T , right: T ) => number
( left: T , right: T ) : number
Parameters
Returns number
skipDuplicates: boolean = false
Returns number
sortedMerge
sortedMerge<T>( array: readonly T [] , values: readonly T [] , compare: ( left: T , right: T ) => number ) : T []
Type parameters
Parameters
array: readonly T []
values: readonly T []
compare: ( left: T , right: T ) => number
( left: T , right: T ) : number
Parameters
Returns number
Returns T []
sortedPickAll
sortedPickAll<T>( array: readonly T [] , values: readonly T [] , compare: ( left: T , right: T ) => number ) : T []
Type parameters
Parameters
array: readonly T []
values: readonly T []
compare: ( left: T , right: T ) => number
( left: T , right: T ) : number
Parameters
Returns number
Returns T []
sortedRemove
sortedRemove<T>( array: T [] , value: T , compare: ( left: T , right: T ) => number ) : T | undefined
Type parameters
Parameters
array: T []
value: T
compare: ( left: T , right: T ) => number
( left: T , right: T ) : number
Parameters
Returns number
Returns T | undefined
Legend
Variable
Function
Function with type parameter
Type alias
Type alias with type parameter
Interface
Interface with type parameter
Class
Class with type parameter
Picks values from the 'array' that are NOT present in 'values'. Both 'array' and 'values' are expected to be sorted.
SortedDifference(["a", "b", "c"], ["b", "c", "d"], (a, b) => a.localeCompare(b)) ==> ["a"]