@figliolia/data-structures
Version:
Efficient data structures for every day programming
51 lines (50 loc) • 1.1 kB
TypeScript
/**
* Quick List
*
* The base construct for `QuickStacks` and `QuickQueues`,
* designed to mimick Array-like interfaces while providing
* access to and deletions of items at O(1)
*/
export declare abstract class QuickList<T> {
storage: Map<string, T>;
private IDs;
/**
* Push
*
* Adds a new item onto the stack, returns a unique
* ID for the item
*/
push(item: T): string;
/**
* Length
*
* Returns the total number of items on the stack
*/
get length(): number;
/**
* Is Empty
*
* Returns true if the list contains no items
*/
get isEmpty(): boolean;
/**
* Get
*
* Returns an item on the stack by unique ID
*/
get(ID: string): T | undefined;
/**
* Delete
*
* Removes an entry from the stack by unique ID
*/
delete(ID: string): boolean;
/**
* Clear
*
* Removes all items from the queue
*/
clear(): void;
[](): Generator<T, void, unknown>;
abstract peek(): [ID: string, item: T] | undefined;
}