Stack
public struct Stack<Element>
extension Stack: Collection
extension Stack: BidirectionalCollection
extension Stack: ExpressibleByArrayLiteral
extension Stack: CustomStringConvertible
extension Stack: Additive
extension Stack: Monoid
extension Stack: Equatable where Element: Equatable
Stack structure.
-
Top element of
Stack.Declaration
Swift
public var top: Element? { get } -
Declaration
Swift
public var destructured: (Element, Stack<Element>)? { get }Return Value
The
topand the remaining items, if possible. Otherwise,nil.
-
Create an empty
Stack.Declaration
Swift
public init() -
Create a
Stackwith the given sequence ofelements.Declaration
Swift
public init<S>(_ elements: S) where Element == S.Element, S : Sequence
-
Push item to end of
Stack.Declaration
Swift
public mutating func push(_ item: Element) -
Declaration
Swift
public func pushing(_ item: Element) -> Stack<Element>Return Value
A new
Stackwith the givenitempushed to the top. -
Declaration
Swift
@discardableResult public mutating func pop() -> Element?Return Value
Item from top of
Stackif there are any. Otherwise,nil. -
Declaration
Swift
public mutating func pop(amount: Int) -> Stack<Element>?Return Value
Stackcontaining items popped from end ofStack
-
Declaration
Swift
public func index(after index: Int) -> IntReturn Value
Index after the given
index. -
- Start index.
Declaration
Swift
public var startIndex: Int { get } -
- End index.
Declaration
Swift
public var endIndex: Int { get } -
Declaration
Swift
public subscript(index: Int) -> Element { get }Return Value
Element at the given
index. -
Count of elements contained herein.
Complexity
O(1)Declaration
Swift
public var count: Int { get } -
Declaration
Swift
public func index(before index: Int) -> IntReturn Value
Index before the given
index.
-
Declaration
Swift
public init(arrayLiteral elements: Element...)Return Value
Create a
SortedArraywith an array literal.
-
Declaration
Swift
public var description: String { get }Return Value
The printed description of this
Stack.
-
Declaration
Swift
public static var zero: Stack<Element> { get }Return Value
Empty
Stack. -
Declaration
Swift
public static func + (lhs: Stack, rhs: Stack) -> StackReturn Value
Stackwith the contents of twoStackvalues.
-
Declaration
Swift
public static var identity: Stack<Element> { get }Return Value
Empty
Stack. -
Declaration
Swift
public static func <> (lhs: Stack<Element>, rhs: Stack<Element>) -> Stack<Element>Return Value
Composition of two of the same
Semigrouptype values.
-
Declaration
Swift
public static func == (lhs: Stack, rhs: Stack) -> BoolReturn Value
trueif twoStackvalues are equivalent. Otherwisefalse.
View on GitHub
Install in Dash
Stack Structure Reference