UNPKG

dastal

Version:

Data Structures & Algorithms implementations

31 lines (30 loc) 831 B
import { List } from '../list'; import { Stack } from './stack'; /** * A linked list implementation of the {@link Stack} interface */ export declare class LinkedStack<T> implements Stack<T> { /** * The list containing every element. */ protected list: List<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>; }