scala.collection.mutable

class MutableList

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

class MutableList[A]
extends LinearSequence[A] with LinearSequenceTemplate[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
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 LinearSequence
companion
Methods inherited from LinearSequenceTemplate
foreach, forall, exists, count, find, foldLeft, foldRight, reduceLeft, reduceRight, take, drop, dropRight, span, sameElements, lengthCompare, isDefinedAt, segmentLength, indexWhere, lastIndexWhere, equals
Methods inherited from Unhashable
hashCode, identityHashCode
Methods inherited from SequenceTemplate
size, zip, zipAll, zipWithIndex, prefixLength, indexWhere, findIndexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexWhere, reverse, reverseIterator, reversedElements, startsWith, startsWith, endsWith, indexOfSeq, indexOfSeq, lastIndexOfSeq, lastIndexOfSeq, contains, union, diff, intersect, removeDuplicates, patch, padTo, toSequence, indices, view, view, toString, sortWith, findLastIndexOf, slice, equalsWith, containsSlice, projection
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from IterableTemplate
elements, toIterable, takeRight, toStream, first, firstOption, toSeq
Methods inherited from TraversableClass
genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableTemplate
thisCollection, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterMap, filterNot, remove, partition, groupBy, /:, :\, reduceLeftOption, reduceRightOption, headOption, lastOption, init, slice, takeWhile, dropWhile, splitAt, copyToBuffer, copyToArray, copyToArray, toArray, toSet, mkString, mkString, mkString, addString, addString, addString, stringPrefix
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
LinearSequenceTemplate.isEmpty

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

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

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

override def apply(n : Int) : A
Returns the nth element of this list.
Throws
IndexOutofBoundsException - if index does not exist.
Overrides
LinearSequenceTemplate.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
LinearSequenceTemplate.iterator

override def last : A
The last element of this linear sequence.
Throws
Predef.NoSuchElementException - if the linear sequence is empty.
Overrides
LinearSequenceTemplate.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