UNPKG

dastal

Version:

Data Structures & Algorithms implementations

30 lines (29 loc) 800 B
import { Stack } from './stack'; /** * An implementation of the {@link Stack} interface using an array */ export declare class ArrayStack<T> implements Stack<T> { /** * The array containing every element. */ protected array: T[]; /** * Instantiate the stack. * * @param elements - A set of elements to initialize the stack with. */ constructor(elements?: Iterable<T>); clear(): void; peek(): T | undefined; pop(): T | undefined; push(element: T): number; get size(): number; /** * Receive an iterator through the stack. * * **Note:** Unexpected behavior can occur if the collection is modified during iteration. * * @returns An iterator through the stack */ [Symbol.iterator](): Iterator<T>; }