summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorRui Gonçalves <ruippeixotog@gmail.com>2015-11-27 00:36:57 +0000
committerRui Gonçalves <ruippeixotog@gmail.com>2015-11-27 00:36:57 +0000
commit2f508a354bcf4028d146c11df30d4059e487e7eb (patch)
tree6c02484077cf3b13a0345328d26a263f4b49f99b /src/library
parent2ef93ad2fe29766fbe09a3e921ad361b25abdeaf (diff)
downloadscala-2f508a354bcf4028d146c11df30d4059e487e7eb.tar.gz
scala-2f508a354bcf4028d146c11df30d4059e487e7eb.tar.bz2
scala-2f508a354bcf4028d146c11df30d4059e487e7eb.zip
SI-9507 Make ArrayStack an IndexedSeqOptimized
Just like `ArraySeq`, `ArrayBuffer` and all other collections that use an array as underlying data structure, `ArrayStack` should also be an instance of `IndexedSeq` and `IndexedSeqOptimized`. As expected by both of the traits, `ArrayStack` has constant-time random element access and length computation.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/mutable/ArrayStack.scala7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala
index 8ff128c026..951a90b084 100644
--- a/src/library/scala/collection/mutable/ArrayStack.scala
+++ b/src/library/scala/collection/mutable/ArrayStack.scala
@@ -64,9 +64,10 @@ object ArrayStack extends SeqFactory[ArrayStack] {
class ArrayStack[T] private(private var table : Array[AnyRef],
private var index : Int)
extends AbstractSeq[T]
- with Seq[T]
- with SeqLike[T, ArrayStack[T]]
+ with IndexedSeq[T]
+ with IndexedSeqLike[T, ArrayStack[T]]
with GenericTraversableTemplate[T, ArrayStack]
+ with IndexedSeqOptimized[T, ArrayStack[T]]
with Cloneable[ArrayStack[T]]
with Builder[T, ArrayStack[T]]
with Serializable
@@ -224,7 +225,7 @@ extends AbstractSeq[T]
/** Creates and iterator over the stack in LIFO order.
* @return an iterator over the elements of the stack.
*/
- def iterator: Iterator[T] = new AbstractIterator[T] {
+ override def iterator: Iterator[T] = new AbstractIterator[T] {
var currentIndex = index
def hasNext = currentIndex > 0
def next() = {