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
top
and the remaining items, if possible. Otherwise,nil
.
-
Create an empty
Stack
.Declaration
Swift
public init()
-
Create a
Stack
with 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
Stack
with the givenitem
pushed to the top. -
Declaration
Swift
@discardableResult public mutating func pop() -> Element?
Return Value
Item from top of
Stack
if there are any. Otherwise,nil
. -
Declaration
Swift
public mutating func pop(amount: Int) -> Stack<Element>?
Return Value
Stack
containing items popped from end ofStack
-
Declaration
Swift
public func index(after index: Int) -> Int
Return 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) -> Int
Return Value
Index before the given
index
.
-
Declaration
Swift
public init(arrayLiteral elements: Element...)
Return Value
Create a
SortedArray
with 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) -> Stack
Return Value
Stack
with the contents of twoStack
values.
-
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
Semigroup
type values.
-
Declaration
Swift
public static func == (lhs: Stack, rhs: Stack) -> Bool
Return Value
true
if twoStack
values are equivalent. Otherwisefalse
.