UNPKG

nope-js-node

Version:

NoPE Runtime for Nodejs. For Browser-Support please use nope-browser

130 lines (129 loc) 3.45 kB
/** * A Priority List. All Items are sorted by a Priority Number. * * @export * @class PriorityList */ export declare class PriorityList<T> { private _priority_list; private _list; private _updated; /** * Function to returns a sorted List containing only the Value * * @returns {Array<T>} Sorted List containing the Values. * @memberof PriorityList */ list(): Array<T>; protected _sort(): void; /** * Adds Data to the Priority List * @param _priority lower => lower priority * @param _data data which are stored */ push(_priority: number, _data: T): void; /** * Returns the Element with the lowest priority * * @param {boolean} [remove=true] Flag to remove the item. Defaults to true. Otherwise it remains in the list. * @return {(T | null)} * @memberof PriorityList */ highest(remove?: boolean): T | null; /** * Returns the Element with the highest priority * @param {boolean} [remove=true] Flag to remove the item. Defaults to true. Otherwise it remains in the list. * @return {(T | null)} * @memberof PriorityList */ lowest(remove?: boolean): T | null; /** * Returns the Length of the Priority list * * @readonly * @type {number} * @memberof PriorityList */ get length(): number; } /** * Limited List. This list at max contains a specific amount of elements. * After the max number of elements has been added, the first element added * will be removed. */ export declare class LimitedList<T> { maxLength: number; /** * Element containing the list * * @private * @type {Array<T>} * @memberof LimitedList */ private _list; /** * Internal Pointer, showing the actual item. * * @private * @type {number} * @memberof LimitedList */ private _pointer; constructor(maxLength: number); /** * Adds Data to the Stack. The Pointer is getting adapted. * * @param {T} data * @returns * @memberof LimitedList */ push(data: T): number; /** * Contains the Length of the list. * * @readonly * @memberof LimitedList */ get length(): number; /** * Gets the current pointer. * * @readonly * @memberof LimitedList */ get currentPointer(): number; last(): T | null; /** * Returns the Pointer to the first item. * @returns */ first(): T | null; /** * Returns the last item. Adapts the pointer and the * current item is the last item. * example: * l = limited.last() * c = limited.current() * * l == c -> True * @returns The last element. */ previous(): T | null; /** * Returns the current item, the pointer is showing at. * @returns */ current(): T | null; next(): T | null; /** * Pops the last element. If there is no element undefined is returned. * @returns The last element. */ pop(current?: boolean): T; /** * Helper to iterate over all items. * @param callbackFn * @param thisArg */ forEach(callbackFn: (item: T, index: number, array: Array<T>) => void, thisArg?: any): void; }