summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/mutable/GenericArray.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2009-11-11 13:05:05 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2009-11-11 13:05:05 +0000
commit446edd332885bf1a26259c220c7880aef59e1163 (patch)
tree5f33896f71ac544568e77b689384873ec50f96f7 /src/library/scala/collection/mutable/GenericArray.scala
parentfc07ece2e71a722dc44d366c8463dd27f825e289 (diff)
downloadscala-446edd332885bf1a26259c220c7880aef59e1163.tar.gz
scala-446edd332885bf1a26259c220c7880aef59e1163.tar.bz2
scala-446edd332885bf1a26259c220c7880aef59e1163.zip
fixed #2546 using patch from dlwh -- please rev...
fixed #2546 using patch from dlwh -- please review!
Diffstat (limited to 'src/library/scala/collection/mutable/GenericArray.scala')
-rw-r--r--src/library/scala/collection/mutable/GenericArray.scala31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/library/scala/collection/mutable/GenericArray.scala b/src/library/scala/collection/mutable/GenericArray.scala
index 3af0ba8118..84341bacd4 100644
--- a/src/library/scala/collection/mutable/GenericArray.scala
+++ b/src/library/scala/collection/mutable/GenericArray.scala
@@ -41,23 +41,6 @@ extends IndexedSeq[A]
array(idx) = elem.asInstanceOf[AnyRef]
}
- /** Fills the given array <code>xs</code> with the elements of
- * this sequence starting at position <code>start</code>.
- *
- * @param xs the array to fill.
- * @param start starting index.
- */
- override def copyToArray[B >: A](xs: Array[B], start: Int) {
- Array.copy(array, 0, xs, start, length)
- }
-
- /** Copy all elements to a buffer
- * @param The buffer to which elements are copied
- override def copyToBuffer[B >: A](dest: Buffer[B]) {
- dest ++= (array: Seq[AnyRef]).asInstanceOf[Seq[B]]
- }
- */
-
override def foreach[U](f: A => U) {
var i = 0
while (i < length) {
@@ -65,6 +48,20 @@ extends IndexedSeq[A]
i += 1
}
}
+
+ /** Fills the given array <code>xs</code> with at most `len` elements of
+ * this traversable starting at position `start`.
+ * Copying will stop once either the end of the current traversable is reached or
+ * `len` elements have been copied or the end of the array is reached.
+ *
+ * @param xs the array to fill.
+ * @param start starting index.
+ * @param len number of elements to copy
+ */
+ override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
+ val len1 = len min (xs.length - start) min length
+ Array.copy(array, 0, xs, start, len1)
+ }
}
object GenericArray extends SeqFactory[GenericArray] {