Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit 3667df1

Browse files
Applying inverse index instead of reversing a List
1 parent 70f0b1d commit 3667df1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/library/scala/collection/immutable/Queue.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class Queue[+A] protected(protected val in: List[A], protected val out: List[A])
6060
if (n < len) out.apply(n)
6161
else {
6262
val m = n - len
63-
if (m < in.length) in.reverse.apply(m)
63+
val l = in.length
64+
if (m < l) in.apply(l - m - 1)
6465
else throw new NoSuchElementException("index out of range")
6566
}
6667
}

0 commit comments

Comments
 (0)