Stack
struct Stack<Element> : Stackable where Element : Equatable
extension Stack: Equatable
extension Stack: CustomStringConvertible
extension Stack: ExpressibleByArrayLiteral
A Stack data structure, implementing Stackable protocol.
-
Uses an array to store the elements of the stack.
Declaration
Swift
private var storage: [Element]
-
Peek to check if there are elements in the underlying data structure.
Declaration
Swift
func peek() -> Element?
-
Pushes an element into the data structure.
Declaration
Swift
mutating func push(_ element: Element)
-
Gets the topmost element from the storage.
Declaration
Swift
mutating func pop() -> Element?
-
Declaration
Swift
static func == (lhs: Stack<Element>, rhs: Stack<Element>) -> Bool
-
Declaration
Swift
var description: String { get }
-
Declaration
Swift
init(arrayLiteral elements: `Self`.Element...)