diff options
author | Tiark Rompf <tiark.rompf@epfl.ch> | 2009-10-21 21:13:58 +0000 |
---|---|---|
committer | Tiark Rompf <tiark.rompf@epfl.ch> | 2009-10-21 21:13:58 +0000 |
commit | 2816f2e6ce51206b3b5bdb1367203bf688625cb6 (patch) | |
tree | b624f91e8b6789f3cdbe216d7f9068edb6cb469b /src/library/scala/collection/mutable/IndexedSeqLike.scala | |
parent | c570e1e7af9762a513f976e4fc5187a6a6efa271 (diff) | |
download | scala-2816f2e6ce51206b3b5bdb1367203bf688625cb6.tar.gz scala-2816f2e6ce51206b3b5bdb1367203bf688625cb6.tar.bz2 scala-2816f2e6ce51206b3b5bdb1367203bf688625cb6.zip |
renamed Vector to IndexedSeq
Diffstat (limited to 'src/library/scala/collection/mutable/IndexedSeqLike.scala')
-rw-r--r-- | src/library/scala/collection/mutable/IndexedSeqLike.scala | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/library/scala/collection/mutable/IndexedSeqLike.scala b/src/library/scala/collection/mutable/IndexedSeqLike.scala new file mode 100644 index 0000000000..74117e3707 --- /dev/null +++ b/src/library/scala/collection/mutable/IndexedSeqLike.scala @@ -0,0 +1,49 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + + +package scala.collection +package mutable +import generic._ + +/** A subtrait of scala.collection.IndexedSeq which represents sequences + * that can be mutated. + * + * @since 2.8 + */ +trait IndexedSeqLike[A, +Repr] extends scala.collection.IndexedSeqLike[A, Repr] { self => + + override protected[this] def thisCollection: IndexedSeq[A] = this.asInstanceOf[IndexedSeq[A]] + override protected[this] def toCollection(repr: Repr): IndexedSeq[A] = repr.asInstanceOf[IndexedSeq[A]] + + def update(idx: Int, elem: A) + + /** Creates a view of this iterable @see Iterable.View + */ + override def view = new IndexedSeqView[A, Repr] { + protected lazy val underlying = self.repr + override def iterator = self.iterator + override def length = self.length + override def apply(idx: Int) = self.apply(idx) + override def update(idx: Int, elem: A) = self.update(idx, elem) + } + + /** A sub-sequence view starting at index `from` + * and extending up to (but not including) index `until`. + * + * @param from The index of the first element of the slice + * @param until The index of the element following the slice + * @note The difference between `view` and `slice` is that `view` produces + * a view of the current sequence, whereas `slice` produces a new sequence. + * + * @note view(from, to) is equivalent to view.slice(from, to) + */ + override def view(from: Int, until: Int) = view.slice(from, until) +} |