Stack

public struct Stack<Element> : CustomStringConvertible where Element : Equatable

Primitive Stack implementation.

  • Returns if the Stack is empty or not.

    Declaration

    Swift

    public func empty() -> Bool

    Return Value

    Returns true if the Stack is empty, otherwise false.

  • Removes an element on top of the Stack.

    Declaration

    Swift

    public mutating func pop() -> Element?

    Return Value

    Returns the removed element.

  • Adds an element on top of the Stack.

    Declaration

    Swift

    public mutating func push(_ element: Element)

    Parameters

    element

    The element to add.