@figliolia/data-structures
Version:
Efficient data structures for every day programming
40 lines (39 loc) • 941 B
TypeScript
/**
* Min Max Stack
*
* The base construct for the MinStack and MaxStack utilities
*/
export declare abstract class MinMaxStack<T> {
readonly storage: T[];
protected occurances: number;
private readonly valueExtractor;
constructor(valueExtractor: (value: T) => number);
/**
* Push
*
* Adds a new value to the stack
*/
push(val: T): void;
/**
* Pop
*
* Removes the most recently added value from the stack
*/
pop(): (T & ({} | null)) | undefined;
/**
* Peek
*
* Returns the most recently added value from the stack
*/
peek(): T;
/**
* Length
*
* Returns the number of items in the stack
*/
get length(): number;
protected abstract findMinMax(value: T): void;
protected abstract setMinMax(value: T): void;
protected extract(value: T): number;
[Symbol.iterator](): Generator<T, void, unknown>;
}