scala.collection.generic

trait TraversableForwarder

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

trait TraversableForwarder[+A]
extends Traversable[A]

This trait implements a forwarder for traversable objects. It forwards all calls to a different iterable object, except for

The above methods are forwarded by subclass TraversableProxy.

Author
Martin Odersky
Version
2.8
Direct Known Subclasses:
IterableForwarder

Method Summary
override def addString (b : StringBuilder, start : java.lang.String, sep : java.lang.String, end : java.lang.String) : StringBuilder
Write all elements of this traversable into given string builder. The written text begins with the string start and is finished by the string end. Inside, the string representations of elements (w.r.t. the method toString()) are separated by the string sep.
override def copyToArray [B >: A](xs : Array[B], start : Int, len : Int) : Unit
Fills the given array xs with at most `len` elements of this traversable starting at position `start`. Copying will stop once either the end of the current traversable is reached or `len` elements have been copied or the end of the array is reached.
override def copyToBuffer [B >: A](dest : Buffer[B]) : Unit
Copy all elements of this traversable to a given buffer
override def count (p : (A) => Boolean) : Int
Count the number of elements in the traversable which satisfy a predicate.
override def exists (p : (A) => Boolean) : Boolean
Return true iff there is an element in this traversable for which the given predicate `p` yields true.
override def find (p : (A) => Boolean) : Option[A]
Find and return the first element of the traversable object satisfying a predicate, if any.
override def foldLeft [B](z : B)(op : (B, A) => B) : B
Combines the elements of this traversable object together using the binary function f, from left to right, and starting with the value z.
override def foldRight [B](z : B)(op : (A, B) => B) : B
Combines the elements of this iterable together using the binary function f, from right to left, and starting with the value z.
override def forall (p : (A) => Boolean) : Boolean
Return true iff the given predicate `p` yields true for all elements of this traversable.
override def foreach [B](f : (A) => B) : Unit
Apply a function f to all elements of this traversable object.
override def hasDefiniteSize : Boolean
Returns true if this collection is known to have finite size. This is the case if the collection type is strict, or if the collection type is non-strict (e.g. it's a Stream), but all collection elements have been computed. Many methods in this trait will not work on collections of infinite sizes.
override def head : A
The first element of this traversable.
override def isEmpty : Boolean
Does this collection contain no elements?
override def last : A
The last element of this traversable.
override def lastOption : Option[A]
Returns as an option the last element of this traversable or None if traversable is empty.
override def mkString (start : java.lang.String, sep : java.lang.String, end : java.lang.String) : java.lang.String
Returns a string representation of this traversable object. The resulting string begins with the string start and is finished by the string end. Inside, the string representations of elements (w.r.t. the method toString()) are separated by the string sep.
override def nonEmpty : Boolean
Does this collection contain some elements?
override def reduceLeft [B >: A](op : (B, A) => B) : B
Combines the elements of this traversable object together using the binary operator op, from left to right
override def reduceLeftOption [B >: A](op : (B, A) => B) : Option[B]
Combines the elements of this traversable object together using the binary operator op, from left to right
override def reduceRight [B >: A](op : (A, B) => B) : B
Combines the elements of this iterable object together using the binary operator op, from right to left
override def reduceRightOption [B >: A](op : (A, B) => B) : Option[B]
Combines the elements of this iterable object together using the binary operator op, from right to left.
override def toArray [B >: A] : Array[B]
Converts this traversable to a fresh Array containing all elements.
override def toList : List[A]
Returns a list with all elements of this traversable object.
override def toSequence : Sequence[A]
Returns a sequence with all elements in this traversable object.
override def toStream : Stream[A]
Returns a stream with all elements in this traversable object.
protected abstract def underlying : Traversable[A]
The iterable object to which calls are forwarded
Methods inherited from Traversable
companion
Methods inherited from TraversableClass
newBuilder, genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableTemplate
thisCollection, size, ++, ++, map, flatMap, filter, filterMap, filterNot, remove, partition, groupBy, /:, :\, headOption, tail, init, take, drop, slice, takeWhile, dropWhile, span, splitAt, copyToArray, toIterable, toSet, mkString, mkString, addString, addString, toString, stringPrefix, view, view
Methods inherited from AnyRef
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
protected abstract def underlying : Traversable[A]
The iterable object to which calls are forwarded

override def isEmpty : Boolean
Does this collection contain no elements?

override def nonEmpty : Boolean
Does this collection contain some elements?

override def hasDefiniteSize : Boolean
Returns true if this collection is known to have finite size. This is the case if the collection type is strict, or if the collection type is non-strict (e.g. it's a Stream), but all collection elements have been computed. Many methods in this trait will not work on collections of infinite sizes.

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. It's important to implement this method in an efficient way.

override def forall(p : (A) => Boolean) : Boolean
Return true iff the given predicate `p` yields true for all elements of this traversable.
Notes
May not terminate for infinite-sized collections.
Parameters
p - the predicate

override def exists(p : (A) => Boolean) : Boolean
Return true iff there is an element in this traversable for which the given predicate `p` yields true.
Notes
May not terminate for infinite-sized collections.
Parameters
p - the predicate

override def count(p : (A) => Boolean) : Int
Count the number of elements in the traversable which satisfy a predicate.
Notes
Will not terminate for infinite-sized collections.
Parameters
p - the predicate for which to count
Returns
the number of elements satisfying the predicate p.

override def find(p : (A) => Boolean) : Option[A]
Find and return the first element of the traversable object satisfying a predicate, if any.
Notes
may not terminate for infinite-sized collections.
Might return different results for different runs, unless this traversable is ordered.
Parameters
p - the predicate
Returns
an option containing the first element in the traversable object satisfying p, or None if none exists.

override def foldLeft[B](z : B)(op : (B, A) => B) : B
Combines the elements of this traversable object together using the binary function f, from left to right, and starting with the value z.
Notes
Will not terminate for infinite-sized collections.
Might return different results for different runs, unless this traversable is ordered, or the operator is associative and commutative.
Returns
f(... (f(f(z, a0), a1) ...), an) if the traversable is [a0, a1, ..., an].

override def foldRight[B](z : B)(op : (A, B) => B) : B
Combines the elements of this iterable together using the binary function f, from right to left, and starting with the value z.
Notes
Will not terminate for infinite-sized collections.
Might return different results for different runs, unless this iterable is ordered, or the operator is associative and commutative.
Returns
f(a0, f(a1, f(..., f(an, z)...))) if the iterable is [a0, a1, ..., an].

override def reduceLeft[B >: A](op : (B, A) => B) : B
Combines the elements of this traversable object together using the binary operator op, from left to right
Notes
Will not terminate for infinite-sized collections.
Might return different results for different runs, unless this traversable is ordered, or the operator is associative and commutative.
Parameters
op - The operator to apply
Returns
op(... op(a0,a1), ..., an) if the traversable object has elements a0, a1, ..., an.
Throws
Predef.UnsupportedOperationException - if the traversable object is empty.

override def reduceRight[B >: A](op : (A, B) => B) : B
Combines the elements of this iterable object together using the binary operator op, from right to left
Notes
Will not terminate for infinite-sized collections.
Might return different results for different runs, unless this iterable is ordered, or the operator is associative and commutative.
Parameters
op - The operator to apply
Returns
a0 op (... op (an-1 op an)...) if the iterable object has elements a0, a1, ..., an.
Throws
Predef.UnsupportedOperationException - if the iterator is empty.

override def reduceLeftOption[B >: A](op : (B, A) => B) : Option[B]
Combines the elements of this traversable object together using the binary operator op, from left to right
Notes
Will not terminate for infinite-sized collections.
Might return different results for different runs, unless this traversable is ordered, or the operator is associative and commutative.
Parameters
op - The operator to apply
Returns
If the traversable is non-empty, the result of the operations as an Option, otherwise None.

override def reduceRightOption[B >: A](op : (A, B) => B) : Option[B]
Combines the elements of this iterable object together using the binary operator op, from right to left.
Notes
Will not terminate for infinite-sized collections.
Might return different results for different runs, unless this iterable is ordered, or the operator is associative and commutative.
Parameters
op - The operator to apply
Returns
If the iterable is non-empty, the result of the operations as an Option, otherwise None.

override def copyToBuffer[B >: A](dest : Buffer[B]) : Unit
Copy all elements of this traversable to a given buffer
Notes
Will not terminate for infinite-sized collections.
Parameters
dest - The buffer to which elements are copied

override def copyToArray[B >: A](xs : Array[B], start : Int, len : Int) : Unit
Fills the given array xs with at most `len` elements of this traversable starting at position `start`. Copying will stop once either the end of the current traversable is reached or `len` elements have been copied or the end of the array is reached.
Notes
Will not terminate for infinite-sized collections.
Parameters
xs - the array to fill.
start - starting index.
len - number of elements to copy

override def toArray[B >: A] : Array[B]
Converts this traversable to a fresh Array containing all elements.
Notes
Will not terminate for infinite-sized collections.

override def toList : List[A]
Returns a list with all elements of this traversable object.
Notes
Will not terminate for infinite-sized collections.

override def toSequence : Sequence[A]
Returns a sequence with all elements in this traversable object.
Notes
Will not terminate for infinite-sized collections.

override def toStream : Stream[A]
Returns a stream with all elements in this traversable object.

override def mkString(start : java.lang.String, sep : java.lang.String, end : java.lang.String) : java.lang.String
Returns a string representation of this traversable object. The resulting string begins with the string start and is finished by the string end. Inside, the string representations of elements (w.r.t. the method toString()) are separated by the string sep.
Examples
List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"
Parameters
start - starting string.
sep - separator string.
end - ending string.
Returns
a string representation of this traversable object.

override def addString(b : StringBuilder, start : java.lang.String, sep : java.lang.String, end : java.lang.String) : StringBuilder
Write all elements of this traversable into given string builder. The written text begins with the string start and is finished by the string end. Inside, the string representations of elements (w.r.t. the method toString()) are separated by the string sep.

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

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

override def lastOption : Option[A]
Returns as an option the last element of this traversable or None if traversable is empty.
Returns
the last element as an option.
Notes
Might return different results for different runs, unless this traversable is ordered