summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/GenSeqLike.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-07-29 23:58:45 +0000
committerPaul Phillips <paulp@improving.org>2011-07-29 23:58:45 +0000
commit67a63278a6c4e9347792219086f11a87d177eee7 (patch)
tree411bab57bbcd9f408ee4230420a7897de952f58b /src/library/scala/collection/GenSeqLike.scala
parentaf412cd72e6e35e7c76ee24e9fa65b73293f0082 (diff)
downloadscala-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/GenSeqLike.scala')
-rw-r--r--src/library/scala/collection/GenSeqLike.scala42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala
index 56034273f0..57e5105e23 100644
--- a/src/library/scala/collection/GenSeqLike.scala
+++ b/src/library/scala/collection/GenSeqLike.scala
@@ -34,6 +34,16 @@ trait GenSeqLike[+A, +Repr] extends GenIterableLike[A, Repr] with Equals with Pa
/** Selects an element by its index in the $coll.
*
+ * Example:
+ *
+ * {{{
+ * scala> val x = LinkedList(1, 2, 3, 4, 5)
+ * x: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4, 5)
+ *
+ * scala> x(3)
+ * res1: Int = 4
+ * }}}
+ *
* @param idx The index to select.
* @return the element of this $coll at index `idx`, where `0` indicates the first element.
* @throws `IndexOutOfBoundsException` if `idx` does not satisfy `0 <= idx < length`.
@@ -263,6 +273,22 @@ trait GenSeqLike[+A, +Repr] extends GenIterableLike[A, Repr] with Equals with Pa
def updated[B >: A, That](index: Int, elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That
/** A copy of the $coll with an element prepended.
+ *
+ * Note that :-ending operators are right associative (see example).
+ * Also, the original $coll is not modified, so you will want to capture the result.
+ *
+ * Example:
+ * {{{
+ * scala> val x = LinkedList(1)
+ * x: scala.collection.mutable.LinkedList[Int] = LinkedList(1)
+ *
+ * scala> val y = 2 +: x
+ * y: scala.collection.mutable.LinkedList[Int] = LinkedList(2, 1)
+ *
+ * scala> println(x)
+ * LinkedList(1)
+ * }}}
+ *
* @param elem the prepended element
* @tparam B the element type of the returned $coll.
* @tparam That $thatinfo
@@ -276,6 +302,7 @@ trait GenSeqLike[+A, +Repr] extends GenIterableLike[A, Repr] with Equals with Pa
def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That
/** A copy of this $coll with an element appended.
+ *
* $willNotTerminateInf
* @param elem the appended element
* @tparam B the element type of the returned $coll.
@@ -286,10 +313,25 @@ trait GenSeqLike[+A, +Repr] extends GenIterableLike[A, Repr] with Equals with Pa
* @usecase def :+(elem: A): $Coll[A]
* @return a new $coll consisting of
* all elements of this $coll followed by `elem`.
+ * @example
+ * {{{
+ * scala> import scala.collection.mutable.LinkedList
+ * import scala.collection.mutable.LinkedList
+ *
+ * scala> val a = LinkedList(1)
+ * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1)
+ *
+ * scala> val b = a :+ 2
+ * b: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2)
+ *
+ * scala> println(a)
+ * LinkedList(1)
+ * }}}
*/
def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That
/** A copy of this $coll with an element value appended until a given target length is reached.
+ *
* @param len the target length
* @param elem the padding value
* @tparam B the element type of the returned $coll.