StackType

protocol StackType

A protocol that describes an instance that can act as a stack data structure

  • pop() Extension method

    Default implementation of popping the last element off the stack

    Declaration

    Swift

    @discardableResult
    mutating func pop() -> StackItem?
  • push(_:) Extension method

    Push a new element on to the stack

    Declaration

    Swift

    mutating func push(_ itemToPush: StackItem)
  • clear() Extension method

    Clear all elements from the stack

    Declaration

    Swift

    mutating func clear()
  • count Extension method

    Returns the number of elements on the stack

    Declaration

    Swift

    var count: Int { get }
  • isEmpty Extension method

    Check whether the stack is empty or not

    Declaration

    Swift

    var isEmpty: Bool { get }
  • last Extension method

    Return the last element on the stack without popping it off the stack. Equivalent to peek in other stack implementations

    Declaration

    Swift

    var last: StackItem? { get }