From cf0390d94e59c637ba83170232864b069b90474e Mon Sep 17 00:00:00 2001 From: Dmitriy Pogretskiy Date: Tue, 14 Jun 2016 15:08:57 +0300 Subject: SI-9817 forall and exists SI-9817 Immutable queue formatting SI-9817 Added comments SI-9817 Comment formatting --- src/library/scala/collection/immutable/Queue.scala | 8 ++++++++ 1 file changed, 8 insertions(+) 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 -- cgit v1.2.3