in scala/collection/mutable
class PriorityQueue

class PriorityQueue[A](view: (A) => Ordered[A])
extends ResizableArray[A]
with ScalaObject
with Cloneable
Implementing classes or objects:
class PriorityQueueProxy[A](view: (A) => Ordered[A])
class SynchronizedPriorityQueue[A](view: (A) => Ordered[A])

This class implements priority queues using a heap. The elements of the queue have to be ordered in terms of the Ordered[T] trait.
Author:
Matthias Zenger
Version:
1.0, 03/05/2004

Method Summary
  def ++=(iter: Iterable[A]): Unit
     Adds all elements provided by an Iterable object into the priority queue.
  def ++=(it: Iterator[A]): Unit
     Adds all elements provided by an iterator into the priority queue.
  def +=(elem: A): Unit
     Inserts a single element into the priority queue.
  def clear: Unit
     Removes all elements from the queue.
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.
  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 toList: List[A]
     Returns a list of all elements.
  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 java/lang/Object-class
eq, finalize, getClass, notify, notifyAll, synchronized, wait, wait, wait

Methods inherited from scala/Any-class
!=, ==, asInstanceOf, isInstanceOf, match

Methods inherited from scala/Iterable-class
/:, :\, exists, find, foldLeft, foldRight, forall, foreach, sameElements

Methods inherited from scala/collection/mutable/ResizableArray-class
array, copy, ensureSize, initialSize, length, size, swap

Method Detail

fixUp

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

fixDown

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

isEmpty

  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 ++=(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

enqueue

  def enqueue(elems: A*): Unit
Adds all elements to the queue.
Parameters:
elems - the elements to add.

dequeue

  def dequeue: A
Returns the element with the highest priority in the queue, and removes this element from the queue.
Returns:
the element with the highest priority.

max

  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.

clear

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

elements

  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.

equals

  override def equals(that: Any): Boolean
Checks if two queues are structurally identical.
Returns:
true, iff both queues contain the same sequence of elements.

hashCode

  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.

toQueue

  def toQueue: Queue[A]
Returns a regular queue containing the same elements.

toList

  def toList: List[A]
Returns a list of all elements.

toString

  override def toString(): String
Returns a textual representation of a queue as a string.
Returns:
the string representation of this queue.

clone

  override def clone(): PriorityQueue[A]
This method clones the priority queue.
Returns:
a priority queue with the same elements.