export default class Stack implements Iterable { #private; /** * Adds an element to the top of the stack. * Time Complexity: O(1) */ push(element: T): void; /** * Removes and returns the top element of the stack. * Returns undefined if the stack is empty. * Time Complexity: O(1) */ pop(): T | undefined; /** * Returns the top element without removing it. * Time Complexity: O(1) */ get top(): T; /** * Overwrites the top element. * Time Complexity: O(1) */ set top(v: T); /** * Alias for top(). Added for compatibility. */ get peek(): T | undefined; /** * Returns the total number of elements in the stack. * Time Complexity: O(1) */ get size(): number; /** * Checks if the stack has no elements. * Time Complexity: O(1) */ get isEmpty(): boolean; /** * Removes all elements from the stack. * Time Complexity: O(1) */ clear(): void; /** * Iterator to iterate from top to bottom. */ [Symbol.iterator](): Iterator; }