diff options
Diffstat (limited to 'src/library/scala/Iterable.scala')
-rw-r--r-- | src/library/scala/Iterable.scala | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/library/scala/Iterable.scala b/src/library/scala/Iterable.scala index 579e249c3f..85d61c7227 100644 --- a/src/library/scala/Iterable.scala +++ b/src/library/scala/Iterable.scala @@ -382,4 +382,22 @@ trait Iterable[+A] { } buf.append(end) } + + /** 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. + * @pre the array must be large enough to hold all elements. + */ + def copyToArray[B >: A](xs: Array[B], start: Int): Unit = + elements.copyToArray(xs, start) + + /** Converts this iterable to a fresh Array with elements. + */ + def toArray[B >: A]: Array[B] = toList.toArray + + /** Is this collection empty? */ + def isEmpty = elements.hasNext + } |