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
bufferSize
The capacity (in terms of elements) of the initial Deque. If unspecified,
Deque
uses 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
elem
to 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
elem
to 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
fn
for each element in the collection untilfn
returns false.Declaration
Parameters
start
Start 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.