import { IIterable, IIterator, IterableOrArrayLike } from '../algorithm/iteration'; /** * A generic LIFO stack data structure. */ export declare class Stack implements IIterable { /** * Construct a new stack. * * @param values - The initial values for the stack. */ constructor(values?: IterableOrArrayLike); /** * Test whether the stack is empty. * * @returns `true` if the stack is empty, `false` otherwise. * * #### Notes * This is a read-only property. * * #### Complexity * Constant. * * #### Iterator Validity * No changes. */ readonly isEmpty: boolean; /** * Get the length of the stack. * * @return The number of values in the stack. * * #### Notes * This is a read-only property. * * #### Complexity * Constant. * * #### Iterator Validity * No changes. */ readonly length: number; /** * Get the value at the back of the stack. * * @returns The value at the back of the stack, or `undefined` if * the stack is empty. * * #### Notes * This is a read-only property. * * #### Complexity * Constant. * * #### Iterator Validity * No changes. */ readonly back: T; /** * Create an iterator over the values in the stack. * * @returns A new iterator starting at the top of the stack. * * #### Complexity * Constant. * * #### Iterator Validity * No changes. */ iter(): IIterator; /** * Add a value to the back of the stack. * * @param value - The value to add to the back of the stack. * * @returns The new length of the stack. * * #### Complexity * Constant. * * #### Iterator Validity * No changes. */ pushBack(value: T): number; /** * Remove and return the value at the back of the stack. * * @returns The value at the back of the stack, or `undefined` if * the stack is empty. * * #### Complexity * Constant. * * #### Iterator Validity * Iterators pointing at the removed value are invalidated. */ popBack(): T; /** * Remove all values from the stack. * * #### Complexity * Linear. * * #### Iterator Validity * All current iterators are invalidated. */ clear(): void; /** * Swap the contents of the stack with the contents of another. * * @param other - The other stack holding the contents to swap. * * #### Complexity * Constant. * * #### Iterator Validity * All current iterators remain valid, but will now point to the * contents of the other stack involved in the swap. */ swap(other: Stack): void; private _array; }