Packages

trait Heap[A] extends Cloneable[Heap[A]]

D-way Heap

The default branching factor is four, which might work in most cases. To create a heap with a different branching factor, use Heap.withBranchingFactor.

There must be implicit scala.math.Ordering available at creation for prioritizing elements. An element with higher order is considered a higher priority.

It's not allowed to insert the same elements. Two elements are considered the same if both have the same hash code. If the same element is inserted, the existing one will be removed. In this case, the priority of the element will update if the new element has a different priority.

As some limitations applied, this heap supports removing the element from any position on logarithmic time.

A

The type of elements in the heap

See also

scala.collection.mutable.PriorityQueue

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Heap
  2. Cloneable
  3. Cloneable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def branchingFactor: Int

    Returns the branching factor of this heap

    Returns the branching factor of this heap

    Note

    Time Complexity: O(1)

  2. abstract def clear(): Heap.this.type

    Removes all elements from this heap

    Removes all elements from this heap

    Note

    Time Complexity: O(1)

  3. abstract def contains(value: A): Boolean

    Returns true if this heap contains the given value

    Returns true if this heap contains the given value

    Note

    Time Complexity: O(1)

  4. abstract def isEmpty: Boolean

    Returns true if this heap is empty

    Returns true if this heap is empty

    Note

    Time Complexity: O(1)

  5. abstract def nonEmpty: Boolean

    Returns true if this heap is not empty

    Returns true if this heap is not empty

    Note

    Time Complexity: O(1)

  6. abstract def ordering: Ordering[A]

    Returns the ordering of this heap

    Returns the ordering of this heap

    Note

    Time Complexity: O(1)

  7. abstract def pop(): A

    Removes and returns the element with the highest priority from this heap

    Removes and returns the element with the highest priority from this heap

    Exceptions thrown

    java.util.NoSuchElementException if this heap is empty

    Note

    Time Complexity: O(log n) amortized

  8. abstract def popAll(): IndexedSeq[A]

    Removes and returns all elements in priority order from this heap

    Removes and returns all elements in priority order from this heap

    Note

    Time Complexity: O(n log n)

  9. abstract def push(value: A): Heap.this.type

    Inserts the given value into this heap

    Inserts the given value into this heap

    If the given value already exists in this heap, the element will be inserted again. The existing one will be removed.

    Note

    Time Complexity: O(log n) amortized

  10. abstract def remove(value: A): Heap.this.type

    Removes the give value from this heap

    Removes the give value from this heap

    If the given value is not in this heap, this method does nothing.

    Note

    Time Complexity: O(log n) amortized

  11. abstract def reversed: Heap[A]

    Returns the reverse of this heap

    Returns the reverse of this heap

    The reversed heap has the same elements of this heap, but the reverse ordering.

    Note

    Time Complexity: O(n)

  12. abstract def size: Int

    Returns the size of this heap

    Returns the size of this heap

    Note

    Time Complexity: O(1)

  13. abstract def top: A

    Returns the element with the highest priority of this heap

    Returns the element with the highest priority of this heap

    Exceptions thrown

    java.util.NoSuchElementException if this heap is empty

    Note

    Time Complexity: O(1)

  14. abstract def topOption: Option[A]

    Returns the element with the highest priority of this heap

    Returns the element with the highest priority of this heap

    If this heap is empty, returns scala.None.

    Note

    Time Complexity: O(1)

  15. abstract def update(oldValue: A, newValue: A): Heap.this.type

    Removes the old value from this heap and inserts the new value into this heap

    Removes the old value from this heap and inserts the new value into this heap

    update(oldValue,newValue) is equivalent to the following calls but more efficient:

    remove(oldValue)
    push(newValue)

    If the old value is not in this heap, this method skips the removal. If the new value already exists in this heap, this method inserts the new element again and removes the existing one.

    Note

    Time Complexity: O(log n) amortized

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): Heap[A]
    Definition Classes
    Cloneable → AnyRef
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  15. def toString(): String
    Definition Classes
    AnyRef → Any
  16. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  17. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  18. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from Cloneable[Heap[A]]

Inherited from Cloneable

Inherited from AnyRef

Inherited from Any

Ungrouped