Container which stores only pairs forming strictly increasing trend in both keys and values. This structure is based on SortedMap.
new MaximaSet()
/**
* 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,
)
length
/**
* Number of pairs in the set.
*
* @readonly
*/
get length(): number;
add()
/**
* 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)
getBest()
/**
* 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
clear()
/**
* Clears the set.
*/
clear(): void;
getFirst()
/**
* Gets X, Y pair with least X.
*
* @returns X, Y pair or undefined if the set is empty.
*/
getFirst(): [X, Y] | undefined;
getLast()
/**
* Gets X, Y pair with greatest X.
*
* @returns X, Y pair or undefined if the set is empty.
*/
getLast(): [X, Y] | undefined;
isEmpty()
/**
* Checks whether the set is empty or not.
*
* @returns TRUE if the map is empty, FALSE otherwise.
*/
isEmpty(): boolean;