Queue
public struct Queue<Element>
First-in-first-out linear data structure.
Remark
Consider using two linked lists instead of anArray as the internal storage.
Array gives O(*n*) performance for remove(at:), which is used by dequeue.
-
Creates an empty
Queue.Declaration
Swift
public init()
-
Declaration
Swift
@inlinable public var isEmpty: Bool { get }Return Value
trueif there are no values contained herein. Otherwise,false. -
Declaration
Swift
@inlinable public var peek: Element? { get }Return Value
The next value to be dequeued, if it exists. Otherwise,
nil.
-
Adds the value to the
Queue.Complexity
O(1) amortizedDeclaration
Swift
@inlinable public mutating func enqueue(_ value: Element)
View on GitHub
Install in Dash
Queue Structure Reference