A Last-In-First-Out (LIFO) stack data structure.

Typeparam

T - The type of elements stored in the stack

Type Parameters

  • T

Constructors

Properties

Methods

Constructors

Properties

top: SingleNode<T> = null

Methods

  • Checks if the stack is empty.

    Returns boolean

    True if the stack contains no elements, false otherwise

  • Returns the element at the top of the stack without removing it.

    Returns T

    The element at the top of the stack

    Throws

    Error if the stack is empty

  • Removes the element from the top of the stack.

    Returns void

    Throws

    Error if the stack is empty

  • Adds an element to the top of the stack.

    Parameters

    • val: T

      The value to add

    Returns void

  • Returns the number of elements in the stack.

    Returns number

    The size of the stack