BinaryHeap

public struct BinaryHeap<Element, Value> where Element : Hashable, Value : Comparable

Implements a priority queue where minimum values have highest priority.

Initializers

  • Create an empty BinaryHeap.

    Declaration

    Swift

    public init()
  • Create a BinaryHeap with the given sequence.

    Declaration

    Swift

    public init<S>(_ sequence: S) where S : Sequence, S.Element == (Element, Value)

Instance Methods

  • Insert element into BinaryHeap instance with associated value value.

    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 or nil if empty.