@figliolia/data-structures
Version:
Efficient data structures for every day programming
34 lines (33 loc) • 915 B
TypeScript
import { QuickList } from "./QuickList";
/**
* Quick Stack
*
* A wrapper around the native Map that assigns an
* auto-incrementing ID to each value added. It provides
* a Stack-like interface with the ability to access and
* remove items in 0(1) time
*
* ```typescript
* const stack = new QuickStack<() => void>();
* const uniqueID = stack.push(() => {});
*
* const FN = stack.pop() // Remove and return the first item on the stack
* const FN = stack.get(uniqueID); // Get an entry by ID
* stack.delete(uniqueID) // Delete an entry by ID
* ```
*/
export declare class QuickStack<T> extends QuickList<T> {
/**
* Pop
*
* Removes and returns the top entry in the stack
*/
pop(): T | undefined;
/**
* Peek
*
* Returns the top entry in the stack
*/
peek(): [string, T] | undefined;
[Symbol.iterator](): Generator<[string, T], void, unknown>;
}