summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable
diff options
context:
space:
mode:
authorDmitriy Pogretskiy <d.pogretskiy@solarsecurity.ru>2016-06-14 15:08:57 +0300
committerDmitriy Pogretskiy <d.pogretskiy@solarsecurity.ru>2016-06-20 12:09:13 +0300
commitcf0390d94e59c637ba83170232864b069b90474e (patch)
treeca5db659d61a62796c2a22b543d9b6573ab33a39 /src/library/scala/collection/immutable
parent79e7334f93da4717ee846f74e48ab53533e6756d (diff)
downloadscala-cf0390d94e59c637ba83170232864b069b90474e.tar.gz
scala-cf0390d94e59c637ba83170232864b069b90474e.tar.bz2
scala-cf0390d94e59c637ba83170232864b069b90474e.zip
SI-9817 forall and exists
SI-9817 Immutable queue formatting SI-9817 Added comments SI-9817 Comment formatting
Diffstat (limited to 'src/library/scala/collection/immutable')
-rw-r--r--src/library/scala/collection/immutable/Queue.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala
index 3ad6656636..1dd0d7683a 100644
--- a/src/library/scala/collection/immutable/Queue.scala
+++ b/src/library/scala/collection/immutable/Queue.scala
@@ -84,6 +84,14 @@ sealed class Queue[+A] protected(protected val in: List[A], protected val out: L
else if (in.nonEmpty) new Queue(Nil, in.reverse.tail)
else throw new NoSuchElementException("tail on empty queue")
+ /* This is made to avoid inefficient implementation of iterator. */
+ override def forall(p: A => Boolean): Boolean =
+ in.forall(p) && out.forall(p)
+
+ /* This is made to avoid inefficient implementation of iterator. */
+ override def exists(p: A => Boolean): Boolean =
+ in.exists(p) || out.exists(p)
+
/** Returns the length of the queue.
*/
override def length = in.length + out.length