Skip to content

Commit a792462

Browse files
committed
Fix List Scaladoc time & space formatting
The Performance section got sucked into a wormhole and popped up in the example tag. The laws of physics differ in the attributes block resulting in the loss of the line break between the Time and Space paragraphs. Fixed by moving the section out of the example tag.
1 parent 72b855f commit a792462

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/library/scala/collection/immutable/List.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ import java.io._
2525
* This class is optimal for last-in-first-out (LIFO), stack-like access patterns. If you need another access
2626
* pattern, for example, random access or FIFO, consider using a collection more suited to this than `List`.
2727
*
28+
* ==Performance==
29+
* '''Time:''' `List` has `O(1)` prepend and head/tail access. Most other operations are `O(n)` on the number of elements in the list.
30+
* This includes the index-based lookup of elements, `length`, `append` and `reverse`.
31+
*
32+
* '''Space:''' `List` implements '''structural sharing''' of the tail list. This means that many operations are either
33+
* zero- or constant-memory cost.
34+
* {{{
35+
* val mainList = List(3, 2, 1)
36+
* val with4 = 4 :: mainList // re-uses mainList, costs one :: instance
37+
* val with42 = 42 :: mainList // also re-uses mainList, cost one :: instance
38+
* val shorter = mainList.tail // costs nothing as it uses the same 2::1::Nil instances as mainList
39+
* }}}
40+
*
2841
* @example {{{
2942
* // Make a list via the companion object factory
3043
* val days = List("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
@@ -41,19 +54,6 @@ import java.io._
4154
* }
4255
* }}}
4356
*
44-
* ==Performance==
45-
* '''Time:''' `List` has `O(1)` prepend and head/tail access. Most other operations are `O(n)` on the number of elements in the list.
46-
* This includes the index-based lookup of elements, `length`, `append` and `reverse`.
47-
*
48-
* '''Space:''' `List` implements '''structural sharing''' of the tail list. This means that many operations are either
49-
* zero- or constant-memory cost.
50-
* {{{
51-
* val mainList = List(3, 2, 1)
52-
* val with4 = 4 :: mainList // re-uses mainList, costs one :: instance
53-
* val with42 = 42 :: mainList // also re-uses mainList, cost one :: instance
54-
* val shorter = mainList.tail // costs nothing as it uses the same 2::1::Nil instances as mainList
55-
* }}}
56-
*
5757
* @note The functional list is characterized by persistence and structural sharing, thus offering considerable
5858
* performance and space consumption benefits in some scenarios if used correctly.
5959
* However, note that objects having multiple references into the same functional list (that is,

0 commit comments

Comments
 (0)