Stack

public struct Stack<Element> where Element : Equatable

Stack data structure

Important

LIFO, Last in First Out
  • All the items/elements in the stack

    Declaration

    Swift

    public var allItems: [Element] { get }
  • Pushes new element inside the stack

    Declaration

    Swift

    public mutating func push(_ element: Element)

    Parameters

    element

    element that needs to be pushed in the stack

  • Pops out the last item from the stack

    Declaration

    Swift

    public mutating func pop() -> Element?

    Return Value

    Poped item