Deque
A dynamically-sized double-ended queue that allows pushing and popping at both the front and the back.
-
The number of elements contained within
self.Declaration
Swift
public private(set) var count: Int -
Creates an empty Deque.
Declaration
Swift
public init(initialCapacity: Int? = nil)Parameters
bufferSizeThe capacity (in terms of elements) of the initial Deque. If unspecified,
Dequeuses a heuristic to pick a value, tuned for performance. -
True iff no values are contained in `self.
Declaration
Swift
public var isEmpty: Bool { get } -
Add
elemto the back ofself.Declaration
Swift
public mutating func pushBack(_ elem: Element) -
Removes and returns the element at the back, reducing
self‘s count by one.Precondition
!isEmptyDeclaration
Swift
public mutating func popBack() -> Element -
Adds
elemto the front ofself.Declaration
Swift
public mutating func pushFront(_ elem: Element) -
Removes and returns the element at the front, reducing
self‘s count by one.Precondition
!isEmptyDeclaration
Swift
public mutating func popFront() -> Element
-
Declaration
Swift
public mutating func pop() -> Element? -
Declaration
Swift
public mutating func push(_ element: Element) -
Declaration
Swift
public struct Cursor : Equatable, Comparable -
Call
fnfor each element in the collection untilfnreturns false.Declaration
Parameters
startStart iterating at elements corresponding to this index. If nil, starts at the beginning of the collection.
Return Value
a cursor into the data structure corresponding to the first element that returns false.
View on GitHub
Deque Structure Reference