BinaryHeap
public struct BinaryHeap<Element, Value> where Element : Hashable, Value : Comparable
Implements a priority queue where minimum values have highest priority.
-
Create an empty
BinaryHeap
.Declaration
Swift
public init()
-
Create a
BinaryHeap
with the givensequence
.Declaration
Swift
public init<S>(_ sequence: S) where S : Sequence, S.Element == (Element, Value)
-
Insert element into
BinaryHeap
instance with associated valuevalue
.Declaration
Swift
public mutating func insert(_ element: Element, _ value: Value)
-
Declaration
Swift
public mutating func pop() -> (Element, Value)?
Return Value
Minimum value element of
BinaryHeap
instance ornil
if empty.