MAIDR Documentation - v3.39.0
    Preparing search index...

    Class Stack<T>

    Generic stack data structure implementation with LIFO (Last In, First Out) behavior.

    Type Parameters

    • T

      The type of elements stored in the stack

    Index

    Constructors

    Methods

    • Adds an item to the top of the stack.

      Parameters

      • item: T

        The item to push onto the stack

      Returns void

    • Removes and returns the top item from the stack.

      Returns T | undefined

      The removed item, or undefined if the stack is empty

    • Returns the top item without removing it from the stack.

      Returns T | undefined

      The top item, or undefined if the stack is empty

    • Removes the last occurrence of a specific element from the stack.

      Parameters

      • element: T

        The element to remove

      • deleteCount: number = 1

        Number of elements to delete (default: 1)

      Returns boolean

      True if the element was found and removed, false otherwise

    • Checks if the stack is empty.

      Returns boolean

      True if the stack contains no items, false otherwise

    • Returns the number of items in the stack.

      Returns number

      The count of items currently in the stack