Stack

open class Stack<T>

Stack. A stack is a collection of elements following a First-In-Last-Out (FILO) order.

Note

Use a Stack if you need a sequence ordered as FILO.
  • true if the stack is empty. false if not.

    Declaration

    Swift

    public var isEmpty: Bool { get }
  • Undocumented

    Declaration

    Swift

    private var storage: [T]
  • Undocumented

    Declaration

    Swift

    public init()
  • Returns the value at the top of the stack.

    Complexity

    O(1)

    Declaration

    Swift

    public func peek() -> T?

    Return Value

    The value at the top of the stack.

  • Adds a value to the top of the stack.

    Complexity

    O(1)

    Declaration

    Swift

    public func push(_ value: T)

    Parameters

    value

    The value to add.

  • Returns the value at the top of the stack and removes it from it.

    Complexity

    O(1)

    Declaration

    Swift

    public func pop() -> T?

    Return Value

    The value at the top of the stack.