scala.collection.mutable

trait LinkedListLike

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

trait LinkedListLike[A, This <: Seq[A] with LinkedListLike[A, This]]
extends SeqLike[A, This]
This extensible class may be used as a basis for implementing linked list. Type variable A refers to the element type of the list, type variable This is used to model self types of linked lists.
Author
Matthias Zenger
Martin Odersky
Version
2.8
Since
2.8
Direct Known Subclasses:
DoubleLinkedListLike, LinkedList

Value Summary
var elem : A
var next : This
Method Summary
def append (that : This) : This
Append linked list `that` at current position of this linked list
override def apply (n : Int) : A
Returns the elements at position `idx`
override def drop (n : Int) : This
Returns this traversable without its n first elements If this traversable has less than n elements, the empty traversable is returned.
override def foreach [B](f : (A) => B) : Unit
Apply a function f to all elements of this iterable object.
def get (n : Int) : Option[A]
override def head : A
The first element of this iterable.
def insert (that : This) : Unit
Insert linked list `that` at current position of this linked list
override def isEmpty : Boolean
Does this iterable contain no elements?
override def iterator : Iterator[A]
Creates a new iterator over all elements contained in this iterable object.
override def length : Int
Returns the length of the sequence.
override def tail : This
a traversable consisting of all elements of this traversable except the first one.
def update (n : Int, x : A) : Unit
Methods inherited from SeqLike
thisCollection, toCollection, lengthCompare, size, isDefinedAt, segmentLength, prefixLength, indexWhere, indexWhere, findIndexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexWhere, 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 IterableLike
elements, forall, exists, find, foldRight, reduceRight, toIterable, take, slice, takeWhile, takeRight, dropRight, copyToArray, zip, zipAll, zipWithIndex, sameElements, toStream, canEqual, first, firstOption
Methods inherited from TraversableLike
newBuilder (abstract), repr, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, count, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, last, lastOption, init, dropWhile, span, splitAt, copyToBuffer, copyToArray, toArray, toList, 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
var elem : A

var next : This

Method Details
override def isEmpty : Boolean
Does this iterable contain no elements?

override def length : Int
Returns the length of the sequence.
Overrides
SeqLike.length

override def head : A
The first element of this iterable.
Notes
Might return different results for different runs, unless this iterable is ordered
Throws
Predef.NoSuchElementException - if the iterable is empty.

override def tail : This
a traversable consisting of all elements of this traversable except the first one.
Notes
Might return different results for different runs, unless this traversable is ordered

def append(that : This) : This
Append linked list `that` at current position of this linked list
Returns
the list after append (this is the list itself if nonempty, or list `that` if list this is empty. )

def insert(that : This) : Unit
Insert linked list `that` at current position of this linked list
Precondition
this linked list is not empty

override def drop(n : Int) : This
Returns this traversable without its n first elements If this traversable has less than n elements, the empty traversable is returned.
Parameters
n - the number of elements to drop
Returns
the new traversable
Notes
Might return different results for different runs, unless this traversable is ordered

override def apply(n : Int) : A
Returns the elements at position `idx`
Overrides
SeqLike.apply

def update(n : Int, x : A) : Unit

def get(n : Int) : Option[A]

override def iterator : Iterator[A]
Creates a new iterator over all elements contained in this iterable object.
Returns
the new iterator

override def foreach[B](f : (A) => B) : Unit
Apply a function f to all elements of this iterable object.
Parameters
f - A function that is applied for its side-effect to every element. The result (of arbitrary type U) of function `f` is discarded.
Notes
This method underlies the implementation of most other bulk operations. Implementing `foreach` with `iterator` is often suboptimal. So `foreach` should be overridden in concrete collection classes if a more efficient implementation is available.