Skip to main content
Module

x/structurae/sorted-array.ts>SortedArray.getRange

Data structures for high-performance JavaScript applications.
Latest
method SortedArray.getRange
import { SortedArray } from "https://deno.land/x/structurae@4.0.1/sorted-array.ts";

Returns a range of elements of a sorted array from the start through the end inclusively.

Examples

SortedArray.getRange([1, 2, 3, 4, 8], 2, 4); //=> [ 2, 3, 4 ]

const customComparator = (a, b) => (a > b ? -1 : a < b ? 1 : 0); SortedArray.getRange([8, 4, 3, 2, 1], 8, 3, customComparator); //=> [ 8, 4, 3 ]

Parameters

arr: U

the array

optional
start: T
optional
end: T
optional
comparator: Comparator<T>
optional
subarray: boolean

Returns

the range of items