export declare class Node { item: Item; next: Node; } /** * The `Stack` class represents a last-in-first-out (LIFO) stack of generic items. * It supports the usual push and pop operations, along with methods * for peeking at the top item, testing if the stack is empty, and iterating through * the items in LIFO order. *

* This implementation uses a singly linked list with a static nested class for * linked-list nodes. See {@link LinkedStack} for the version from the * textbook that uses a non-static nested class. * See {@link ResizingArrayStack} for a version that uses a resizing array. * The push, pop, peek, size, and is-empty * operations all take constant time in the worst case. *

* For additional documentation, * see Section 1.3 of * Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne. * * @param the generic type of an item in this stack */ export default class Stack implements Iterable { private first; private n; private modCount; constructor(); /** * Returns true if this stack is empty. * * @return true if this stack is empty; false otherwise */ isEmpty(): boolean; /** * Returns the number of items in this stack. * * @return the number of items in this stack */ size(): number; /** * Adds the item to this stack. * * @param item the item to add */ push(item: Item): void; /** * Removes and returns the item most recently added to this stack. * * @return the item most recently added * @throws Error if this stack is empty */ pop(): Item; /** * Returns (but does not remove) the item most recently added to this stack. * * @return the item most recently added to this stack * @throws Error if this stack is empty */ peek(): Item; /** * Returns a string representation of this stack. * * @return the sequence of items in this stack in LIFO order, separated by spaces */ toString(): string; /** * Returns an iterator to this stack that iterates through the items in LIFO order. * * @return an iterator to this stack that iterates through the items in LIFO order */ [Symbol.iterator](): { next(): IteratorResult; }; }