scala.collection.mutable

class MutableList

[source: scala/collection/mutable/MutableList.scala]

@serializable

@SerialVersionUID(5938451523372603072L)

class MutableList[A]
extends LinearSeq[A] with LinearSeqLike[A, MutableList[A]] with Builder[A, MutableList[A]]

This class is used internally to represent mutable lists. It is the basis for the implementation of the classes Stack, and Queue.

!!! todo: convert to LinkedListBuffer?
Author
Matthias Zenger
Martin Odersky
Version
2.8
Since
1
Direct Known Subclasses:
Queue

Value Summary
protected var first0 : LinkedList[A]
protected var last0 : LinkedList[A]
protected var len : Int
Method Summary
def += (elem : A) : MutableList[A]
Appends a single element to this buffer. This takes constant time.
protected def appendElem (elem : A) : Unit
override def apply (n : Int) : A
Returns the nth element of this list.
def clear : Unit
Clear the contents of this builder
def get (n : Int) : Option[A]
Returns the nth element of this list or None if index does not exist.
override def head : A
Returns the first element in this list
override def isEmpty : Boolean
Is the list empty?
override def iterator : Iterator[A]
Returns an iterator over all elements of this list.
override def last : A
The last element of this linear sequence.
override def length : Int
Returns the length of this list.
protected[this] override def newBuilder : MutableList[A]
The builder that builds instances of CC[A]
protected def prependElem (elem : A) : Unit
def reset : Unit
def result : MutableList[A]
Returns collection resulting from this builder. The buffer's contents are undefined afterwards.
override def tail : MutableList[A]
Returns the rest of this list
override def toList : List[A]
Returns an instance of scala.List containing the same sequence of elements.
def update (n : Int, x : A) : Unit
Updates the nth element of this list to a new value.
Methods inherited from Builder
sizeHint, mapResult
Methods inherited from Growable
+=, ++=, ++=
Methods inherited from LinearSeq
companion
Methods inherited from LinearSeqLike
thisCollection, toCollection, foreach, forall, exists, count, find, foldLeft, foldRight, reduceLeft, reduceRight, take, drop, dropRight, slice, takeWhile, span, sameElements, lengthCompare, isDefinedAt, segmentLength, indexWhere, lastIndexWhere
Methods inherited from SeqLike
size, prefixLength, indexWhere, findIndexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexWhere, reverse, reverseMap, reverseIterator, reversedElements, startsWith, startsWith, endsWith, indexOfSeq, indexOfSeq, lastIndexOfSeq, lastIndexOfSeq, contains, union, diff, intersect, removeDuplicates, patch, updated, +:, :+, padTo, sortWith, sortWith, sortBy, toSeq, indices, view, view, hashCode, equals, toString, findLastIndexOf, equalsWith, containsSlice, projection
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from IterableLike
elements, toIterable, takeRight, copyToArray, zip, zipAll, zipWithIndex, toStream, canEqual, first, firstOption
Methods inherited from GenericTraversableTemplate
genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableLike
repr, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, /:, :\, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, lastOption, init, dropWhile, splitAt, copyToBuffer, copyToArray, toArray, toIndexedSeq, toSet, mkString, mkString, mkString, addString, addString, addString, stringPrefix, withFilter
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
protected var first0 : LinkedList[A]

protected var last0 : LinkedList[A]

protected var len : Int

Method Details
protected[this] override def newBuilder : MutableList[A]
The builder that builds instances of CC[A]

override def isEmpty : Boolean
Is the list empty?
Overrides
LinearSeqLike.isEmpty

override def head : A
Returns the first element in this list
Overrides
LinearSeqLike.head

override def tail : MutableList[A]
Returns the rest of this list
Overrides
LinearSeqLike.tail

override def length : Int
Returns the length of this list.
Overrides
LinearSeqLike.length

override def apply(n : Int) : A
Returns the nth element of this list.
Throws
IndexOutofBoundsException - if index does not exist.
Overrides
LinearSeqLike.apply

def update(n : Int, x : A) : Unit
Updates the nth element of this list to a new value.
Throws
IndexOutofBoundsException - if index does not exist.

def get(n : Int) : Option[A]
Returns the nth element of this list or None if index does not exist.

protected def prependElem(elem : A) : Unit

protected def appendElem(elem : A) : Unit

@deprecated("use clear instead")

def reset : Unit

override def iterator : Iterator[A]
Returns an iterator over all elements of this list.
Overrides
LinearSeqLike.iterator

override def last : A
The last element of this linear sequence.
Throws
Predef.NoSuchElementException - if the linear sequence is empty.
Overrides
LinearSeqLike.last

override def toList : List[A]
Returns an instance of scala.List containing the same sequence of elements.

def +=(elem : A) : MutableList[A]
Appends a single element to this buffer. This takes constant time.
Parameters
elem - the element to append.
Overrides
Builder.+=

def clear : Unit
Clear the contents of this builder
Overrides
Builder.clear

def result : MutableList[A]
Returns collection resulting from this builder. The buffer's contents are undefined afterwards.
Overrides
Builder.result