diff options
author | Paul Phillips <paulp@improving.org> | 2011-07-29 23:58:45 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-07-29 23:58:45 +0000 |
commit | 67a63278a6c4e9347792219086f11a87d177eee7 (patch) | |
tree | 411bab57bbcd9f408ee4230420a7897de952f58b /src/library/scala/collection/TraversableLike.scala | |
parent | af412cd72e6e35e7c76ee24e9fa65b73293f0082 (diff) | |
download | scala-67a63278a6c4e9347792219086f11a87d177eee7.tar.gz scala-67a63278a6c4e9347792219086f11a87d177eee7.tar.bz2 scala-67a63278a6c4e9347792219086f11a87d177eee7.zip |
- Update Scaladoc for LinkedList and for some o...
- Update Scaladoc for LinkedList and for some of the functions/operators
- that it inherits. Completed Scaladoc for append Added example
- in GenSeqLike for apply. Added $collectExample to collect in
- GenTraversableLike and supplied an actual example in LinkedList
Contributed by Donald McLean.
Diffstat (limited to 'src/library/scala/collection/TraversableLike.scala')
-rw-r--r-- | src/library/scala/collection/TraversableLike.scala | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index 1f6c6ff0bb..e3d51fde4e 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -157,10 +157,22 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = ++(that: GenTraversableOnce[B])(bf) - /** Concatenates this $coll with the elements of a traversable collection. + /** As with `++`, returns a new collection containing the elements from the left operand followed by the + * elements from the right operand. * It differs from `++` in that the right operand determines the type of * the resulting collection rather than the left one. * + * Example: + * {{{ + * scala> val x = List(1) + * x: List[Int] = List(1) + * + * scala> val y = LinkedList(2) + * y: scala.collection.mutable.LinkedList[Int] = LinkedList(2) + * + * scala> val z = x ++: y + * z: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2) + * }}} * @param that the traversable to append. * @tparam B the element type of the returned collection. * @tparam That $thatinfo @@ -181,12 +193,39 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] b.result } - /** This overload exists because: for the implementation of `++`: we should + /** As with `++`, returns a new collection containing the elements from the left operand followed by the + * elements from the right operand. + * It differs from `++` in that the right operand determines the type of + * the resulting collection rather than the left one. + * + * Example: + * {{{ + * scala> val x = List(1) + * x: List[Int] = List(1) + * + * scala> val y = LinkedList(2) + * y: scala.collection.mutable.LinkedList[Int] = LinkedList(2) + * + * scala> val z = x ++: y + * z: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2) + * }}} + * + * This overload exists because: for the implementation of `++:` we should * reuse that of `++` because many collections override it with more * efficient versions. * * Since `TraversableOnce` has no `++` method, we have to implement that * directly, but `Traversable` and down can use the overload. + * + * @param that the traversable to append. + * @tparam B the element type of the returned collection. + * @tparam That $thatinfo + * @param bf $bfinfo + * @return a new collection of type `That` which contains all elements + * of this $coll followed by all elements of `that`. + * + * @return a new $coll which contains all elements of this $coll + * followed by all elements of `that`. */ def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = (that ++ seq)(breakOut) |