From 97b9978b85ff841e540d13a585e074252c747fba Mon Sep 17 00:00:00 2001 From: Aleksandar Pokopec Date: Wed, 13 Apr 2011 16:32:04 +0000 Subject: Further fixes #4405. No review. --- src/library/scala/collection/mutable/PriorityQueue.scala | 8 ++++++++ src/library/scala/collection/mutable/PriorityQueueProxy.scala | 8 ++++++++ .../scala/collection/mutable/SynchronizedPriorityQueue.scala | 8 ++++++++ 3 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala index 1f7e4e7879..8eb72fada7 100644 --- a/src/library/scala/collection/mutable/PriorityQueue.scala +++ b/src/library/scala/collection/mutable/PriorityQueue.scala @@ -158,6 +158,14 @@ class PriorityQueue[A](implicit val ord: Ordering[A]) b.result } + /** 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. + */ + @deprecated("Use `head` instead.") + def max: A = if (resarr.p_size0 > 1) toA(resarr.p_array(1)) else throw new NoSuchElementException("queue is empty") + /** Returns the element with the highest priority in the queue, * or throws an error if there is no element contained in the queue. * diff --git a/src/library/scala/collection/mutable/PriorityQueueProxy.scala b/src/library/scala/collection/mutable/PriorityQueueProxy.scala index f8330c3aac..912786359a 100644 --- a/src/library/scala/collection/mutable/PriorityQueueProxy.scala +++ b/src/library/scala/collection/mutable/PriorityQueueProxy.scala @@ -73,6 +73,14 @@ abstract class PriorityQueueProxy[A](implicit ord: Ordering[A]) extends Priority * * @return the element with the highest priority. */ + override def head: A = self.head + + /** 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. + */ + @deprecated("Use `head` instead.") override def max: A = self.max /** Removes all elements from the queue. After this operation is completed, diff --git a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala index 3295b43d7f..523f5154e0 100644 --- a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala +++ b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala @@ -71,6 +71,14 @@ class SynchronizedPriorityQueue[A](implicit ord: Ordering[A]) extends PriorityQu * * @return the element with the highest priority. */ + override def head: A = synchronized { super.head } + + /** 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. + */ + @deprecated("Use `head` instead.") override def max: A = synchronized { super.max } /** Removes all elements from the queue. After this operation is completed, -- cgit v1.2.3