summaryrefslogtreecommitdiff
path: root/src/library/scalax/collection/generic/Growable.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-02-13 11:59:49 +0000
committerMartin Odersky <odersky@gmail.com>2009-02-13 11:59:49 +0000
commit04840e2ed4530df9a5ca59b984bf2b37a976dc70 (patch)
tree61394762e202f8ab60e0d3a8e8ac688404241bc3 /src/library/scalax/collection/generic/Growable.scala
parent708baf94764e2a839e24ca6204060a8d0664d88c (diff)
downloadscala-04840e2ed4530df9a5ca59b984bf2b37a976dc70.tar.gz
scala-04840e2ed4530df9a5ca59b984bf2b37a976dc70.tar.bz2
scala-04840e2ed4530df9a5ca59b984bf2b37a976dc70.zip
new version of collection libraries
Diffstat (limited to 'src/library/scalax/collection/generic/Growable.scala')
-rwxr-xr-xsrc/library/scalax/collection/generic/Growable.scala58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/library/scalax/collection/generic/Growable.scala b/src/library/scalax/collection/generic/Growable.scala
new file mode 100755
index 0000000000..960384f9d0
--- /dev/null
+++ b/src/library/scalax/collection/generic/Growable.scala
@@ -0,0 +1,58 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
+
+package scalax.collection.generic
+
+/** This class represents collections that can be augmented using a += operator.
+ *
+ * @autor Martin Odersky
+ * @owner Martin Odersky
+ * @version 2.8
+ */
+trait Growable[A] {
+
+ /** Adds a single element to this collection.
+ *
+ * @param elem the element to add.
+ */
+ def +=(elem: A): Unit
+
+ /** Adds two or more elements to this collection.
+ *
+ * @param elem1 the first element to add.
+ * @param elem2 the second element to add.
+ * @param elems the remaining elements to add.
+ */
+ def +=(elem1: A, elem2: A, elems: A*) {
+ this += elem1
+ this += elem2
+ this ++= elems.asInstanceOf[Iterable[A]] // !@!
+ }
+
+ /** Adds a number of elements provided by an iterator to this collection.
+ *
+ * @param iter the iterator.
+ */
+ def ++=(iter: collection.Iterator[A]) { iter foreach += }
+
+ /** Adds a number of elements provided by an iterable object to this collection.
+ *
+ * @param iter the iterable object.
+ */
+ def ++=(iter: collection.Iterable[A]) { iter foreach += }
+
+ /** Clears the collection contents.
+ */
+ def clear()
+}
+
+
+
+