MaximaSet
Container which stores only pairs forming strictly increasing trend in both keys and values. This structure is based on SortedMap.
Last updated
Was this helpful?
Container which stores only pairs forming strictly increasing trend in both keys and values. This structure is based on SortedMap.
Last updated
Was this helpful?
Was this helpful?
/**
* Creates an instance of MaximaSet.
*
* @param iterable Iterable of X, Y pairs to create the new maxima set with.
* @param compareX Comparison function for pairs sorting by X values. Xs are compared as numbers by default.
* @param compareY Comparison function for pairs sorting by Y values. Ys are compared as numbers by default.
*/
constructor(
iterable: Iterable<[X, Y]> = [],
protected compareX: CompareFunc<X> = compareAsNumbers,
protected compareY: CompareFunc<Y> = compareAsNumbers,
)
/**
* Number of pairs in the set.
*
* @readonly
*/
get length(): number;
/**
* Adds X, Y pair to the maxima set if there is no better pair in it.
*
* @param x X value.
* @param y Y value.
*/
add(x: X, y: Y)
/**
* Gets X, Y pair with largest X not exceeding the specified value.
*
* @param x X value.
* @returns X, Y pair or undefined if the set is empty.
*/
getBest(x: X): [X, Y] | undefined
/**
* Clears the set.
*/
clear(): void;
/**
* Gets X, Y pair with least X.
*
* @returns X, Y pair or undefined if the set is empty.
*/
getFirst(): [X, Y] | undefined;
/**
* Gets X, Y pair with greatest X.
*
* @returns X, Y pair or undefined if the set is empty.
*/
getLast(): [X, Y] | undefined;
/**
* Checks whether the set is empty or not.
*
* @returns TRUE if the map is empty, FALSE otherwise.
*/
isEmpty(): boolean;
[Symbol.iterator](): IterableIterator<[X, Y]>