scala.collection.mutable
class PriorityQueue

[source: `scala/collection/mutable/PriorityQueue.scala`]

@serializable
@cloneable
`` `class` PriorityQueue[A](`implicit` view$0 : (A) => Ordered[A])
  `extends` ResizableArray[A]

  This class implements priority queues using a heap. The elements of the queue have to be ordered in terms of the `Ordered[T]` class.

Author
  Matthias Zenger
Version
  1.0, 03/05/2004

Direct Known Subclasses:
  PriorityQueueProxy, SynchronizedPriorityQueue

Values and Variables inherited from ResizableArray
initialSize, array, size0

Method Summary
`def` | + (elem : A) : PriorityQueue[A]
`def` | + (elem1 : A, elem2 : A, elems : A*) : PriorityQueue[A]
`def` | ++ (iter : Iterable[A]) : PriorityQueue[A]
`def` | ++ (iter : Iterator[A]) : PriorityQueue[A]
`def` | ++= (it : Iterator[A]) : Unit Adds all elements provided by an iterator into the priority queue.
`def` | ++= (iter : Iterable[A]) : Unit Adds all elements provided by an `Iterable` object into the priority queue.
`def` | += (elem : A) : Unit Inserts a single element into the priority queue.
`def` | += (elem1 : A, elem2 : A, elems : A*) : Unit Add two or more elements to this set.
`def` | clear : Unit Removes all elements from the queue. After this operation is completed, the queue will be empty.
`override def` | clone : PriorityQueue[A] This method clones the priority queue.
`def` | dequeue : A Returns the element with the highest priority in the queue, and removes this element from the queue.
`override def` | elements : Iterator[A] Returns an iterator which yiels all the elements of the priority queue in descending priority order.
`def` | enqueue (elems : A*) : Unit Adds all elements to the queue.
`override def` | equals (that : Any) : Boolean Checks if two queues are structurally identical.
`protected def` | fixDown (as : Array[A], m : Int, n : Int) : Unit
`protected def` | fixUp (as : Array[A], m : Int) : Unit
`override def` | hashCode : Int The hashCode method always yields an error, since it is not safe to use mutable queues as keys in hash tables.
`override def` | isEmpty : Boolean Checks if the queue is empty.
`def` | max : A Returns the element with the highest priority in the queue, or throws an error if there is no element contained in the queue.
`def` | toQueue : Queue[A] Returns a regular queue containing the same elements.
`override def` | toString : String Returns a textual representation of a queue as a string.

Methods inherited from ResizableArray
length, apply, copyToArray, copyToBuffer, ensureSize, swap, copy

Methods inherited from Seq
size, concat, ++, isDefinedAt, lastIndexOf, map, flatMap, filter, take, drop, takeWhile, dropWhile, reverse, contains, slice, subseq, toArray

Methods inherited from Collection
stringPrefix

Methods inherited from Iterable
foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, sameElements, toList, mkString, mkString, addString, addString, projection, hasDefiniteSize

Methods inherited from PartialFunction
orElse, andThen

Methods inherited from Function1
compose

Methods inherited from AnyRef
getClass, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized

Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf

Method Details

`protected` `def` fixUp(as : Array[A], m : Int) : Unit

`protected` `def` fixDown(as : Array[A], m : Int, n : Int) : Unit

`override` `def` isEmpty : Boolean

  Checks if the queue is empty.

Returns
  true, iff there is no element in the queue.

`` `def` +=(elem : A) : Unit

  Inserts a single element into the priority queue.

Parameters
  `elem -` the element to insert

`` `def` +(elem : A) : PriorityQueue[A]

`` `def` +=(elem1 : A, elem2 : A, elems : A*) : Unit

  Add two or more elements to this set.

Parameters
  `elem1 -` the first element.
  `kv2 -` the second element.
  `kvs -` the remaining elements.

`` `def` +(elem1 : A, elem2 : A, elems : A*) : PriorityQueue[A]

`` `def` ++=(iter : Iterable[A]) : Unit

  Adds all elements provided by an `Iterable` object into the priority queue.

Parameters
  `iter -` an iterable object

`` `def` ++=(it : Iterator[A]) : Unit

  Adds all elements provided by an iterator into the priority queue.

Parameters
  `it -` an iterator

`` `def` ++(iter : Iterable[A]) : PriorityQueue[A]

`` `def` ++(iter : Iterator[A]) : PriorityQueue[A]

`` `def` enqueue(elems : A*) : Unit

  Adds all elements to the queue.

Parameters
  `elems -` the elements to add.

`` `def` dequeue : A

  Returns the element with the highest priority in the queue, and removes this element from the queue.

Throws
  Predef.NoSuchElementException -
Returns
  the element with the highest priority.

`` `def` max : A

  Returns the element with the highest priority in the queue, or throws an error if there is no element contained in the queue.

Returns
  the element with the highest priority.

`` `def` clear : Unit

  Removes all elements from the queue. After this operation is completed, the queue will be empty.

`override` `def` elements : Iterator[A]

  Returns an iterator which yiels all the elements of the priority queue in descending priority order.

Returns
  an iterator over all elements sorted in descending order.

Overrides ResizableArray.elements

`override` `def` equals(that : Any) : Boolean

  Checks if two queues are structurally identical.

Returns
  true, iff both queues contain the same sequence of elements.

`override` `def` hashCode : Int

  The hashCode method always yields an error, since it is not safe to use mutable queues as keys in hash tables.

Returns
  never.

`` `def` toQueue : Queue[A]

  Returns a regular queue containing the same elements.

`override` `def` toString : String

  Returns a textual representation of a queue as a string.

Returns
  the string representation of this queue.

`override` `def` clone : PriorityQueue[A]

  This method clones the priority queue.

Returns
  a priority queue with the same elements.