scala.collection.generic

trait LinkedListTemplate

[source: scala/collection/generic/LinkedListTemplate.scala]

trait LinkedListTemplate[A, This <: Sequence[A] with LinkedListTemplate[A, This] >: Null]
extends SequenceTemplate[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. !!! todo: integrate with LinearSequence, need to drop null then.
Author
Matthias Zenger
Martin Odersky
Version
2.8
Direct Known Subclasses:
DoubleLinkedListTemplate, LinkedList

Value Summary
var elem : A
var next : This
Method Summary
def append (that : This) : Unit
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 traversable object.
def get (n : Int) : Option[A]
override def head : A
The first element of this iterable.
def insert (that : This) : Unit
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
An traversable consisting of all elements of this traversable except the first one.
def update (n : Int, x : A) : Unit
Methods inherited from SequenceTemplate
lengthCompare, size, isDefinedAt, zip, zipAll, zipWithIndex, segmentLength, prefixLength, indexWhere, indexWhere, findIndexOf, indexOf, indexOf, lastIndexOf, lastIndexOf, lastIndexWhere, lastIndexWhere, reverse, reverseIterator, reversedElements, startsWith, startsWith, endsWith, indexOfSeq, indexOfSeq, lastIndexOfSeq, lastIndexOfSeq, contains, union, diff, intersect, removeDuplicates, patch, padTo, toSequence, indices, view, view, equals, toString, sortWith, findLastIndexOf, slice, equalsWith, containsSlice, projection
Methods inherited from IterableTemplate
elements, foldRight, reduceRight, toIterable, takeRight, dropRight, sameElements, toStream, first, firstOption, toSeq
Methods inherited from TraversableTemplate
newBuilder (abstract), thisCollection, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterMap, filterNot, remove, partition, groupBy, forall, exists, count, find, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, headOption, last, lastOption, init, take, slice, takeWhile, dropWhile, span, splitAt, copyToBuffer, copyToArray, copyToArray, toArray, toList, toSet, mkString, mkString, mkString, addString, addString, addString, stringPrefix
Methods inherited from AnyRef
getClass, hashCode, 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.
Returns
the sequence length.
Overrides
SequenceTemplate.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
An 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) : Unit

def insert(that : This) : Unit

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
SequenceTemplate.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 traversable 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.