Stack
Undocumented
-
Undocumented
-
Undocumented
-
Undocumented
-
Undocumented
-
Undocumented
-
Element order is [top, …, bottom], as if one were to iterate through the sequence in reverse, calling
stack.push(element)on each element.Declaration
Swift
public init<S : SequenceType where S.Generator.Element == Element>(_ elements:S) -
Adds an element to the top of the stack.
Declaration
Swift
public mutating func push(elem: Element)Parameters
elemThe element to add.
-
Removes the top element from the stack and returns it.
Declaration
Swift
public mutating func pop() -> Element?Return Value
The removed element or
nilif the stack is empty. -
Returns the element at the specified index, or nil if the index was out of range.
Declaration
Swift
public func at(index i:Int) -> Element? -
Returns the index of the first element for which
predicatereturns true.Declaration
Swift
public func find(predicate: (Element) -> Bool) -> Index? -
Inserts the provided element
npositions from the top of the stack. The index must be >= startIndex and <= endIndex or a precondition will fail. Insert can therefore be used to append and prepend elements to the list (and, in fact,appendandprependsimply call this function).Declaration
Swift
public mutating func insert(newElement:Element, atIndex i:Index.RawIndex) -
Undocumented
-
Removes the element
npositions from the top of the stack and returns it.indexmust be a valid index or a precondition assertion will fail.Declaration
Swift
public mutating func removeAtIndex(index:Index) -> ElementParameters
indexThe index of the element to remove.
Return Value
The removed element.
-
Undocumented
-
This function is equivalent to
pop(), except that it will fail if the stack is empty.Declaration
Swift
public mutating func removeTop() -> ElementReturn Value
The removed element.
View on GitHub
Stack Struct Reference