summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/List.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-11-24 10:17:40 +0100
committerLukas Rytz <lukas.rytz@gmail.com>2015-11-24 10:17:40 +0100
commit86300fe1b3ab87b2e40616ed78709e8f03e707b5 (patch)
tree4458169015b02ecf7e29f805d0dbd6645171620a /src/library/scala/collection/immutable/List.scala
parent3d0cbf9d10416fab8017b5fb46af44f59ee89fd1 (diff)
parent8eb1d4c29d85aef7828eeb35169e80c085cea93e (diff)
downloadscala-86300fe1b3ab87b2e40616ed78709e8f03e707b5.tar.gz
scala-86300fe1b3ab87b2e40616ed78709e8f03e707b5.tar.bz2
scala-86300fe1b3ab87b2e40616ed78709e8f03e707b5.zip
Merge commit '8eb1d4c' into merge-2.11-to-2.12-nov-24
Diffstat (limited to 'src/library/scala/collection/immutable/List.scala')
-rw-r--r--src/library/scala/collection/immutable/List.scala26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index 66150c1a13..3ad567375c 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -25,6 +25,19 @@ import java.io.{ObjectOutputStream, ObjectInputStream}
* This class is optimal for last-in-first-out (LIFO), stack-like access patterns. If you need another access
* pattern, for example, random access or FIFO, consider using a collection more suited to this than `List`.
*
+ * ==Performance==
+ * '''Time:''' `List` has `O(1)` prepend and head/tail access. Most other operations are `O(n)` on the number of elements in the list.
+ * This includes the index-based lookup of elements, `length`, `append` and `reverse`.
+ *
+ * '''Space:''' `List` implements '''structural sharing''' of the tail list. This means that many operations are either
+ * zero- or constant-memory cost.
+ * {{{
+ * val mainList = List(3, 2, 1)
+ * val with4 = 4 :: mainList // re-uses mainList, costs one :: instance
+ * val with42 = 42 :: mainList // also re-uses mainList, cost one :: instance
+ * val shorter = mainList.tail // costs nothing as it uses the same 2::1::Nil instances as mainList
+ * }}}
+ *
* @example {{{
* // Make a list via the companion object factory
* val days = List("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
@@ -41,19 +54,6 @@ import java.io.{ObjectOutputStream, ObjectInputStream}
* }
* }}}
*
- * ==Performance==
- * '''Time:''' `List` has `O(1)` prepend and head/tail access. Most other operations are `O(n)` on the number of elements in the list.
- * This includes the index-based lookup of elements, `length`, `append` and `reverse`.
- *
- * '''Space:''' `List` implements '''structural sharing''' of the tail list. This means that many operations are either
- * zero- or constant-memory cost.
- * {{{
- * val mainList = List(3, 2, 1)
- * val with4 = 4 :: mainList // re-uses mainList, costs one :: instance
- * val with42 = 42 :: mainList // also re-uses mainList, cost one :: instance
- * val shorter = mainList.tail // costs nothing as it uses the same 2::1::Nil instances as mainList
- * }}}
- *
* @note The functional list is characterized by persistence and structural sharing, thus offering considerable
* performance and space consumption benefits in some scenarios if used correctly.
* However, note that objects having multiple references into the same functional list (that is,