summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/mutable/PriorityQueueProxy.scala
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2005-12-19 13:49:03 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2005-12-19 13:49:03 +0000
commitac849228490d5a0e2d3f048d649297d5c59b6ade (patch)
tree6314f2c06f37e67dec5827c3f94e25cf844a085c /src/library/scala/collection/mutable/PriorityQueueProxy.scala
parentd6c0efe5b4b89a0337f1cdcdabf8c607d81f4ae1 (diff)
downloadscala-ac849228490d5a0e2d3f048d649297d5c59b6ade.tar.gz
scala-ac849228490d5a0e2d3f048d649297d5c59b6ade.tar.bz2
scala-ac849228490d5a0e2d3f048d649297d5c59b6ade.zip
Switching to the new build system and to the ne...
Switching to the new build system and to the new build system. This is a MAJOR commit, so be careful when updating.
Diffstat (limited to 'src/library/scala/collection/mutable/PriorityQueueProxy.scala')
-rw-r--r--src/library/scala/collection/mutable/PriorityQueueProxy.scala94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/library/scala/collection/mutable/PriorityQueueProxy.scala b/src/library/scala/collection/mutable/PriorityQueueProxy.scala
new file mode 100644
index 0000000000..e78b98065f
--- /dev/null
+++ b/src/library/scala/collection/mutable/PriorityQueueProxy.scala
@@ -0,0 +1,94 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+** $Id$
+\* */
+
+package scala.collection.mutable;
+
+
+/** This class implements priority queues using a heap. The
+ * elements of the queue have to be ordered in terms of the
+ * <code>Ordered[T]</code> trait.
+ *
+ * @author Matthias Zenger
+ * @version 1.0, 03/05/2004
+ */
+abstract class PriorityQueueProxy[A <% Ordered[A]] extends PriorityQueue[A] with IterableProxy[A] {
+
+ def self: PriorityQueue[A];
+
+ /** Creates a new iterator over all elements contained in this
+ * object.
+ *
+ * @return the new iterator
+ */
+ override def elements: Iterator[A] = self.elements;
+
+ /** Returns the length of this priority queue.
+ */
+ override def length: Int = self.length;
+
+ /** Checks if the queue is empty.
+ *
+ * @return true, iff there is no element in the queue.
+ */
+ override def isEmpty: Boolean = self.isEmpty;
+
+ /** Inserts a single element into the priority queue.
+ *
+ * @param elem the element to insert
+ */
+ override def +=(elem: A): Unit = self += elem;
+
+ /** Adds all elements provided by an <code>Iterable</code> object
+ * into the priority queue.
+ *
+ * @param iter an iterable object
+ */
+ override def ++=(iter: Iterable[A]): Unit = self ++= iter;
+
+ /** Adds all elements provided by an iterator into the priority queue.
+ *
+ * @param it an iterator
+ */
+ override def ++=(it: Iterator[A]): Unit = self ++= it;
+
+ /** Adds all elements to the queue.
+ *
+ * @param elems the elements to add.
+ */
+ override def enqueue(elems: A*): Unit = self ++= elems;
+
+ /** Returns the element with the highest priority in the queue,
+ * and removes this element from the queue.
+ *
+ * @return the element with the highest priority.
+ */
+ override def dequeue: A = self.dequeue;
+
+ /** Returns the element with the highest priority in the queue,
+ * or throws an error if there is no element contained in the queue.
+ *
+ * @return the element with the highest priority.
+ */
+ override def max: A = self.max;
+
+ /** Removes all elements from the queue. After this operation is completed,
+ * the queue will be empty.
+ */
+ override def clear: Unit = self.clear;
+
+ /** Returns a regular queue containing the same elements.
+ */
+ override def toQueue: Queue[A] = self.toQueue;
+
+ /** This method clones the priority queue.
+ *
+ * @return a priority queue with the same elements.
+ */
+ override def clone(): PriorityQueue[A] = new PriorityQueueProxy[A] { def self = PriorityQueueProxy.this.self.clone() }
+}