Scala Library: scala.collection.mutable.LinkedList
scala.collection.mutable.LinkedList
object LinkedList extends SeqFactory[LinkedList] with Serializable
This object provides a set of operations to create LinkedList
values.
- Annotations
- @ deprecated
- Deprecated
- (Since version 2.11.0) Low-level linked lists are deprecated.
- Source
Type Members
type Coll = LinkedList[_]
The underlying collection type with unknown element type
- Attributes
- protected[this]
- Definition Classes
- GenericCompanion
class GenericCanBuildFrom[A] extends CanBuildFrom[CC[_], A, CC[A]]
A generic implementation of the CanBuildFrom
trait, which forwards all calls
to apply(from)
to the genericBuilder
method of collection from
, and which
forwards all calls of apply()
to the newBuilder
method of this factory.
- Definition Classes
- GenTraversableFactory
Value Members From scala.collection.generic.GenTraversableFactory
def ReusableCBF: GenericCanBuildFrom[Nothing]
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def concat[A](xss: collection.Traversable[A]*): LinkedList[A]
Concatenates all argument collections into a single collection.
- xss
- the collections that are to be concatenated.
- returns
- the concatenation of all the collections.
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def fill[A](n: Int)(elem: ⇒ A): LinkedList[A]
Produces a collection containing the results of some element computation a number of times.
- n
- the number of elements contained in the collection.
- elem
- the element computation
- returns
- A collection that contains the results of
n
evaluations ofelem
.
- A collection that contains the results of
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def fill[A](n1: Int, n2: Int)(elem: ⇒ A): LinkedList[LinkedList[A]]
Produces a two-dimensional collection containing the results of some element computation a number of times.
- n1
- the number of elements in the 1st dimension
- n2
- the number of elements in the 2nd dimension
- elem
- the element computation
- returns
- A collection that contains the results of
n1 x n2
evaluations ofelem
.
- A collection that contains the results of
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def fill[A](n1: Int, n2: Int, n3: Int)(elem: ⇒ A): LinkedList[LinkedList[LinkedList[A]]]
Produces a three-dimensional collection containing the results of some element computation a number of times.
- n1
- the number of elements in the 1st dimension
- n2
- the number of elements in the 2nd dimension
- n3
- the number of elements in the 3nd dimension
- elem
- the element computation
- returns
- A collection that contains the results of
n1 x n2 x n3
evaluations ofelem
.
- A collection that contains the results of
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def fill[A](n1: Int, n2: Int, n3: Int, n4: Int)(elem: ⇒ A): LinkedList[LinkedList[LinkedList[LinkedList[A]]]]
Produces a four-dimensional collection containing the results of some element computation a number of times.
- n1
- the number of elements in the 1st dimension
- n2
- the number of elements in the 2nd dimension
- n3
- the number of elements in the 3nd dimension
- n4
- the number of elements in the 4th dimension
- elem
- the element computation
- returns
- A collection that contains the results of
n1 x n2 x n3 x n4
evaluations ofelem
.
- A collection that contains the results of
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def fill[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: ⇒ A): LinkedList[LinkedList[LinkedList[LinkedList[LinkedList[A]]]]]
Produces a five-dimensional collection containing the results of some element computation a number of times.
- n1
- the number of elements in the 1st dimension
- n2
- the number of elements in the 2nd dimension
- n3
- the number of elements in the 3nd dimension
- n4
- the number of elements in the 4th dimension
- n5
- the number of elements in the 5th dimension
- elem
- the element computation
- returns
- A collection that contains the results of
n1 x n2 x n3 x n4 x n5
evaluations ofelem
.
- A collection that contains the results of
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def iterate[A](start: A, len: Int)(f: (A) ⇒ A): LinkedList[A]
Produces a collection containing repeated applications of a function to a start value.
- start
- the start value of the collection
- len
- the number of elements contained inthe collection
- f
- the function that’s repeatedly applied
- returns
- a collection with
len
values in the sequencestart, f(start), f(f(start)), ...
- a collection with
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def range[T](start: T, end: T)(implicit arg0: Integral[T]): LinkedList[T]
Produces a collection containing a sequence of increasing of integers.
- start
- the first element of the collection
- end
- the end value of the collection (the first value NOT contained)
- returns
- a collection with values
start, start + 1, ..., end - 1
- a collection with values
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def range[T](start: T, end: T, step: T)(implicit arg0: Integral[T]): LinkedList[T]
Produces a collection containing equally spaced values in some integer interval.
- start
- the start value of the collection
- end
- the end value of the collection (the first value NOT contained)
- step
- the difference between successive elements of the collection (must be positive or negative)
- returns
- a collection with values
start, start + step, ...
up to, but excludingend
- a collection with values
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def tabulate[A](n: Int)(f: (Int) ⇒ A): LinkedList[A]
Produces a collection containing values of a given function over a range of integer values starting from 0.
- n
- The number of elements in the collection
- f
- The function computing element values
- returns
- A collection consisting of elements
f(0), ..., f(n -1)
- A collection consisting of elements
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def tabulate[A](n1: Int, n2: Int)(f: (Int, Int) ⇒ A): LinkedList[LinkedList[A]]
Produces a two-dimensional collection containing values of a given function over ranges of integer values starting from 0.
- n1
- the number of elements in the 1st dimension
- n2
- the number of elements in the 2nd dimension
- f
- The function computing element values
- returns
- A collection consisting of elements
f(i1, i2)
for0 <= i1 < n1
and0 <= i2 < n2
.
- A collection consisting of elements
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def tabulate[A](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) ⇒ A): LinkedList[LinkedList[LinkedList[A]]]
Produces a three-dimensional collection containing values of a given function over ranges of integer values starting from 0.
- n1
- the number of elements in the 1st dimension
- n2
- the number of elements in the 2nd dimension
- n3
- the number of elements in the 3nd dimension
- f
- The function computing element values
- returns
- A collection consisting of elements
f(i1, i2, i3)
for0 <= i1 < n1
,0 <= i2 < n2
, and0 <= i3 < n3
.
- A collection consisting of elements
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) ⇒ A): LinkedList[LinkedList[LinkedList[LinkedList[A]]]]
Produces a four-dimensional collection containing values of a given function over ranges of integer values starting from 0.
- n1
- the number of elements in the 1st dimension
- n2
- the number of elements in the 2nd dimension
- n3
- the number of elements in the 3nd dimension
- n4
- the number of elements in the 4th dimension
- f
- The function computing element values
- returns
- A collection consisting of elements
f(i1, i2, i3, i4)
for0 <= i1 < n1
,0 <= i2 < n2
,0 <= i3 < n3
, and0 <= i4 < n4
.
- A collection consisting of elements
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(f: (Int, Int, Int, Int, Int) ⇒ A): LinkedList[LinkedList[LinkedList[LinkedList[LinkedList[A]]]]]
Produces a five-dimensional collection containing values of a given function over ranges of integer values starting from 0.
- n1
- the number of elements in the 1st dimension
- n2
- the number of elements in the 2nd dimension
- n3
- the number of elements in the 3nd dimension
- n4
- the number of elements in the 4th dimension
- n5
- the number of elements in the 5th dimension
- f
- The function computing element values
- returns
- A collection consisting of elements
f(i1, i2, i3, i4, i5)
for0 <= i1 < n1
,0 <= i2 < n2
,0 <= i3 < n3
,0 <= i4 < n4
, and0 <= i5 < n5
.
- A collection consisting of elements
- Definition Classes
- GenTraversableFactory
(defined at scala.collection.generic.GenTraversableFactory)
Value Members From scala.collection.generic.GenericCompanion
def apply[A](elems: A*): LinkedList[A]
Creates a collection with the specified elements.
- A
- the type of the collection’s elements
- elems
- the elements of the created collection
- returns
- a new collection with elements
elems
- a new collection with elements
- Definition Classes
- GenericCompanion
(defined at scala.collection.generic.GenericCompanion)
Value Members From scala.collection.generic.SeqFactory
def unapplySeq[A](x: LinkedList[A]): Some[LinkedList[A]]
This method is called in a pattern match { case Seq(…) => }.
- x
- the selector value
- returns
- sequence wrapped in an option, if this is a Seq, otherwise none
- Definition Classes
- SeqFactory
(defined at scala.collection.generic.SeqFactory)
Value Members From scala.collection.mutable.LinkedList
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, LinkedList[A]]
(defined at scala.collection.mutable.LinkedList)
def empty[A]: LinkedList[A]
An empty collection of type LinkedList[A]
- A
- the type of the linked list’s elements
- Definition Classes
- LinkedList → GenericCompanion
(defined at scala.collection.mutable.LinkedList)
def newBuilder[A]: Builder[A, LinkedList[A]]
The default builder for LinkedList
objects.
- A
- the type of the linked list’s elements
- Definition Classes
- LinkedList → GenericCompanion (defined at scala.collection.mutable.LinkedList)
Full Source:
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala
package collection
package mutable
import generic._
/** A more traditional/primitive style of linked list where the "list" is also the "head" link. Links can be manually
* created and manipulated, though the use of the API, when possible, is recommended.
*
* The danger of directly manipulating next:
* {{{
* scala> val b = LinkedList(1)
* b: scala.collection.mutable.LinkedList[Int] = LinkedList(1)
*
* scala> b.next = null
*
* scala> println(b)
* java.lang.NullPointerException
* }}}
*
* $singleLinkedListExample
*
* @author Matthias Zenger
* @author Martin Odersky
* @version 2.8
* @since 1
* @see [[http://docs.scala-lang.org/overviews/collections/concrete-mutable-collection-classes.html#linked_lists "Scala's Collection Library overview"]]
* section on `Linked Lists` for more information.
*
* @tparam A the type of the elements contained in this linked list.
*
* @constructor Creates an "empty" list, defined as a single node with no data element and next pointing to itself.
* @define Coll `LinkedList`
* @define coll linked list
* @define thatinfo the class of the returned collection. In the standard library configuration,
* `That` is always `LinkedList[B]` because an implicit of type `CanBuildFrom[LinkedList, B, LinkedList[B]]`
* is defined in object `LinkedList`.
* @define bfinfo an implicit value of class `CanBuildFrom` which determines the
* result class `That` from the current representation type `Repr`
* and the new element type `B`. This is usually the `canBuildFrom` value
* defined in object `LinkedList`.
* @define orderDependent
* @define orderDependentFold
* @define mayNotTerminateInf
* @define willNotTerminateInf
* @define collectExample Example:
* {{{
* scala> val a = LinkedList(1, 2, 3)
* a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3)
*
* scala> val addOne: PartialFunction[Any, Float] = {case i: Int => i + 1.0f}
* addOne: PartialFunction[Any,Float] = <function1>
*
* scala> val b = a.collect(addOne)
* b: scala.collection.mutable.LinkedList[Float] = LinkedList(2.0, 3.0, 4.0)
*
* scala> val c = LinkedList('a')
* c: scala.collection.mutable.LinkedList[Char] = LinkedList(a)
*
* scala> val d = a ++ c
* d: scala.collection.mutable.LinkedList[AnyVal] = LinkedList(1, 2, 3, a)
*
* scala> val e = d.collect(addOne)
* e: scala.collection.mutable.LinkedList[Float] = LinkedList(2.0, 3.0, 4.0)
* }}}
*/
@SerialVersionUID(-7308240733518833071L)
@deprecated("Low-level linked lists are deprecated due to idiosyncrasies in interface and incomplete features.", "2.11.0")
class LinkedList[A]() extends AbstractSeq[A]
with LinearSeq[A]
with GenericTraversableTemplate[A, LinkedList]
with LinkedListLike[A, LinkedList[A]]
with Serializable {
next = this
/** Creates a new list. If the parameter next is null, the result is an empty list. Otherwise, the result is
* a list with elem at the head, followed by the contents of next.
*
* Note that next is part of the new list, as opposed to the +: operator,
* which makes a new copy of the original list.
*
* @example
* {{{
* scala> val m = LinkedList(1)
* m: scala.collection.mutable.LinkedList[Int] = LinkedList(1)
*
* scala> val n = new LinkedList[Int](2, m)
* n: scala.collection.mutable.LinkedList[Int] = LinkedList(2, 1)
* }}}
*/
def this(elem: A, next: LinkedList[A]) {
this()
if (next != null) {
this.elem = elem
this.next = next
}
}
override def companion: GenericCompanion[LinkedList] = LinkedList
}
/** $factoryInfo
* @define Coll `LinkedList`
* @define coll linked list
*/
@deprecated("Low-level linked lists are deprecated.", "2.11.0")
object LinkedList extends SeqFactory[LinkedList] {
override def empty[A]: LinkedList[A] = new LinkedList[A]
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, LinkedList[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
def newBuilder[A]: Builder[A, LinkedList[A]] =
(new MutableList) mapResult ((l: MutableList[A]) => l.toLinkedList)
}
Interested in Scala?
I send out weekly, personalized emails with articles and conference talks.
Subscribe now.