summaryrefslogtreecommitdiff
path: root/src/library/scalax/collection/mutable/ListBuffer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-02-05 19:25:43 +0000
committerMartin Odersky <odersky@gmail.com>2009-02-05 19:25:43 +0000
commit0ecacced0347e4e3b83989a274b9de53868a3a57 (patch)
treecf5bb351b3acef82ad88862bee320b9c6e32a4c3 /src/library/scalax/collection/mutable/ListBuffer.scala
parent48355ee28a930f19000901d761f24ca44b324c1f (diff)
downloadscala-0ecacced0347e4e3b83989a274b9de53868a3a57.tar.gz
scala-0ecacced0347e4e3b83989a274b9de53868a3a57.tar.bz2
scala-0ecacced0347e4e3b83989a274b9de53868a3a57.zip
added support for Strings, arrays, sets.
Diffstat (limited to 'src/library/scalax/collection/mutable/ListBuffer.scala')
-rw-r--r--src/library/scalax/collection/mutable/ListBuffer.scala15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/library/scalax/collection/mutable/ListBuffer.scala b/src/library/scalax/collection/mutable/ListBuffer.scala
index 3b7587d6d2..dff29f6453 100644
--- a/src/library/scalax/collection/mutable/ListBuffer.scala
+++ b/src/library/scalax/collection/mutable/ListBuffer.scala
@@ -11,10 +11,15 @@
package scalax.collection.mutable
-import generic.SequenceForwarder
+import generic.{SequenceForwarder, SequenceFactory, SequenceTemplate}
import immutable.List
import collection.immutable.{List, Nil, ::}
+/* Factory object for `ListBuffer` class */
+object ListBuffer extends SequenceFactory[ListBuffer] {
+ def apply[A](args: A*): ListBuffer[A] = new ListBuffer[A]
+}
+
/** A Buffer implementation back up by a list. It provides constant time
* prepend and append. Most other operations are linear.
*
@@ -25,9 +30,12 @@ import collection.immutable.{List, Nil, ::}
@serializable
final class ListBuffer[A]
extends Buffer[A]
+ with SequenceTemplate[ListBuffer, A]
with Builder[List, A]
with SequenceForwarder[A]
{
+ import collection.immutable.Sequence
+
private var start: List[A] = Nil
private var last0: ::[A] = _
private var exported: Boolean = false
@@ -178,8 +186,7 @@ final class ListBuffer[A]
} catch {
case ex: Exception =>
throw new IndexOutOfBoundsException(n.toString())
- }
- }
+ } }
// Implementation of abstract method in Builder
@@ -258,7 +265,7 @@ final class ListBuffer[A]
}
/** expose the underlying list but do not mark it as exported */
- override def readOnly : List[A] = start
+ def readOnly: List[A] = start
// Private methods