scala

trait IterableProxy

[source: scala/IterableProxy.scala]

trait IterableProxy[+A]
extends Iterable[A] with Proxy
This class implements a proxy for iterable objects. It forwards all calls to a different iterable object.
Author
Matthias Zenger
Martin Odersky
Version
2.0, 31/12/2006
Direct Known Subclasses:
CollectionProxy, SetProxy

Method Summary
override def ++ [B >: A](that : Iterable[B]) : Collection[B]
Appends two iterable objects.
override def /: [B](z : B)(op : (B, A) => B) : B
Similar to foldLeft but can be used as an operator with the order of list and zero arguments reversed. That is, z /: xs is the same as xs foldLeft z
override def :\ [B](z : B)(op : (A, B) => B) : B
An alias for foldRight. That is, xs :\ z is the same as xs foldRight z
override def addString (buf : StringBuilder, sep : java.lang.String) : StringBuilder
Write all elements of this string into given string builder.
override def addString (buf : StringBuilder, start : java.lang.String, sep : java.lang.String, end : java.lang.String) : StringBuilder
Write all elements of this string into given string builder.
override def addString (buf : StringBuilder) : StringBuilder
Write all elements of this string into given string builder, with no separator string between elements.
override def concat [B >: A](that : Iterable[B]) : Collection[B]
Appends two iterable objects.
override def copyToArray [B >: A](xs : Array[B], start : Int) : Unit
Fills the given array xs with the elements of this sequence starting at position start.
override def copyToBuffer [B >: A](dest : Buffer[B]) : Unit
Copy all elements to a given buffer
override def drop (n : Int) : Collection[A]
Returns this iterable without its n first elements If this iterable has less than n elements, the empty iterable is returned.
override def dropWhile (p : (A) => Boolean) : Collection[A]
Returns the longest suffix of this iterable whose first element does not satisfy the predicate p.
override def elements : Iterator[A]
Creates a new iterator over all elements contained in this object.
override def exists (p : (A) => Boolean) : Boolean
Apply a predicate p to all elements of this iterable object and return true, iff there is at least one element for which p yields true.
override def filter (p : (A) => Boolean) : Iterable[A]
Returns all the elements of this iterable that satisfy the predicate p. The order of the elements is preserved.
override def find (p : (A) => Boolean) : Option[A]
Find and return the first element of the iterable object satisfying a predicate, if any.
override def findIndexOf (p : (A) => Boolean) : Int
Returns index of the first element satisying a predicate, or -1.
override def flatMap [B](f : (A) => Iterable[B]) : Iterable[B]
Applies the given function f to each element of this iterable, then concatenates the results.
override def foldLeft [B](z : B)(op : (B, A) => B) : B
Combines the elements of this iterable 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 list together using the binary function f, from right to left, and starting with the value z.
override def forall (p : (A) => Boolean) : Boolean
Apply a predicate p to all elements of this iterable object and return true, iff the predicate yields true for all elements.
override def foreach (f : (A) => Unit) : Unit
Apply a function f to all elements of this iterable object.
override def hasDefiniteSize : Boolean
returns true iff this collection has a bound size. Many APIs in this trait will not work on collections of unbound sizes.
override def indexOf [B >: A](elem : B) : Int
Returns the index of the first occurence of the specified object in this iterable object.
override def isEmpty : Boolean
Is this collection empty?
override def map [B](f : (A) => B) : Iterable[B]
Returns the iterable resulting from applying the given function f to each element of this iterable.
override def mkString (sep : java.lang.String) : java.lang.String
Returns a string representation of this iterable object. The string representations of elements (w.r.t. the method toString()) are separated by the string sep.
override def mkString : java.lang.String
Converts a collection into a flat String by each element's toString method.
override def mkString (start : java.lang.String, sep : java.lang.String, end : java.lang.String) : java.lang.String
Returns a string representation of this iterable 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 partition (p : (A) => Boolean) : (Iterable[A], Iterable[A])
Partitions this iterable in two iterables according to a predicate.
override def projection : Projection[A]
returns a projection that can be used to call non-strict filter, map, and flatMap methods that build projections of the collection.
override def reduceLeft [B >: A](op : (B, A) => B) : B
Combines the elements of this iterable 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 sameElements [B >: A](that : Iterable[B]) : Boolean
Checks if the other iterable object contains the same elements.
override abstract def self : Iterable[A]
override def take (n : Int) : Collection[A]
Returns an iterable consisting only over the first n elements of this iterable, or else the whole iterable, if it has less than n elements.
override def takeWhile (p : (A) => Boolean) : Iterable[A]
Returns the longest prefix of this iterable whose elements satisfy the predicate p.
override def toList : List[A]
Returns a list containing all of the elements in this iterable object.
override def toSeq : Seq[A]
Returns a sequence containing all of the elements in this iterable object.
override def toStream : Stream[A]
Returns a stream containing all of the elements in this iterable object.
Methods inherited from Proxy
hashCode, equals, toString
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
override abstract def self : Iterable[A]
Overrides
Proxy.self

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

@deprecated

override def concat[B >: A](that : Iterable[B]) : Collection[B]
Appends two iterable objects.
Returns
the new iterable object
Deprecated
use ++ instead
Notes
Will not terminate for infinite-sized collections.
Overrides
Iterable.concat

override def ++[B >: A](that : Iterable[B]) : Collection[B]
Appends two iterable objects.
Returns
the new iterable object
Notes
Will not terminate for infinite-sized collections.
Overrides
Iterable.++

override def map[B](f : (A) => B) : Iterable[B]
Returns the iterable resulting from applying the given function f to each element of this iterable.
Notes
Will not terminate for infinite-sized collections.
Parameters
f - function to apply to each element.
Returns
f(a0), ..., f(an) if this iterable is a0, ..., an.
Overrides
Iterable.map

override def flatMap[B](f : (A) => Iterable[B]) : Iterable[B]
Applies the given function f to each element of this iterable, then concatenates the results.
Notes
Will not terminate for infinite-sized collections.
Parameters
f - the function to apply on each element.
Returns
f(a0) ::: ... ::: f(an) if this iterable is a0, ..., an.
Overrides
Iterable.flatMap

override def filter(p : (A) => Boolean) : Iterable[A]
Returns all the elements of this iterable that satisfy the predicate p. The order of the elements is preserved.
Notes
Will not terminate for infinite-sized collections.
Parameters
p - the predicate used to filter the list.
Returns
the elements of this list satisfying p.
Overrides
Iterable.filter

override def partition(p : (A) => Boolean) : (Iterable[A], Iterable[A])
Partitions this iterable in two iterables according to a predicate.
Parameters
p - the predicate on which to partition
Returns
a pair of iterables: the iterable that satisfy the predicate p and the iterable that do not. The relative order of the elements in the resulting iterables is the same as in the original iterable.
Overrides
Iterable.partition

override def takeWhile(p : (A) => Boolean) : Iterable[A]
Returns the longest prefix of this iterable whose elements satisfy the predicate p.
Notes
May not terminate for infinite-sized collections.
Parameters
p - the test predicate.
Returns
the longest prefix of this iterable whose elements satisfy the predicate p.
Overrides
Iterable.takeWhile

override def dropWhile(p : (A) => Boolean) : Collection[A]
Returns the longest suffix of this iterable whose first element does not satisfy the predicate p.
Notes
May not terminate for infinite-sized collections.
Parameters
p - the test predicate.
Returns
the longest suffix of the iterable whose first element does not satisfy the predicate p.
Overrides
Iterable.dropWhile

@deprecated

override def take(n : Int) : Collection[A]
Returns an iterable consisting only over the first n elements of this iterable, or else the whole iterable, if it has less than n elements.
Deprecated
API does not make sense for non-ordered collections
Parameters
n - the number of elements to take
Returns
the new iterable
Overrides
Iterable.take

@deprecated

override def drop(n : Int) : Collection[A]
Returns this iterable without its n first elements If this iterable has less than n elements, the empty iterable is returned.
Notes
Will not terminate for infinite-sized collections.
Deprecated
API does not make sense for non-ordered collections
Parameters
n - the number of elements to drop
Returns
the new iterable
Overrides
Iterable.drop

override def foreach(f : (A) => Unit) : Unit
Apply a function f to all elements of this iterable object.
Notes
Will not terminate for infinite-sized collections.
Parameters
f - a function that is applied to every element.
Overrides
Iterable.foreach

override def forall(p : (A) => Boolean) : Boolean
Apply a predicate p to all elements of this iterable object and return true, iff the predicate yields true for all elements.
Notes
May not terminate for infinite-sized collections.
Parameters
p - the predicate
Returns
true, iff the predicate yields true for all elements.
Overrides
Iterable.forall

override def exists(p : (A) => Boolean) : Boolean
Apply a predicate p to all elements of this iterable object and return true, iff there is at least one element for which p yields true.
Notes
May not terminate for infinite-sized collections.
Parameters
p - the predicate
Returns
true, iff the predicate yields true for at least one element.
Overrides
Iterable.exists

override def find(p : (A) => Boolean) : Option[A]
Find and return the first element of the iterable object satisfying a predicate, if any.
Notes
may not terminate for infinite-sized collections.
Parameters
p - the predicate
Returns
the first element in the iterable object satisfying p, or None if none exists.
Overrides
Iterable.find

@deprecated

override def findIndexOf(p : (A) => Boolean) : Int
Returns index of the first element satisying a predicate, or -1.
Notes
may not terminate for infinite-sized collections.
Parameters
p - the predicate
Returns
the index of the first element satisfying p, or -1 if such an element does not exist
Deprecated
Method is pushed to Seq, will be removed from Iterable.
Overrides
Iterable.findIndexOf

@deprecated

override def indexOf[B >: A](elem : B) : Int
Returns the index of the first occurence of the specified object in this iterable object.
Notes
may not terminate for infinite-sized collections.
Parameters
elem - element to search for.
Returns
the index in this sequence of the first occurence of the specified element, or -1 if the sequence does not contain this element.
Deprecated
Method is pushed to Seq, will be removed from Iterable.
Overrides
Iterable.indexOf

override def foldLeft[B](z : B)(op : (B, A) => B) : B
Combines the elements of this iterable 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.
Returns
f(... (f(f(z, a0), a1) ...), an) if the list is [a0, a1, ..., an].
Overrides
Iterable.foldLeft

override def foldRight[B](z : B)(op : (A, B) => B) : B
Combines the elements of this list together using the binary function f, from right to left, and starting with the value z.
Notes
Will not terminate for infinite-sized collections.
Returns
f(a0, f(a1, f(..., f(an, z)...))) if the list is [a0, a1, ..., an].
Overrides
Iterable.foldRight

override def /:[B](z : B)(op : (B, A) => B) : B
Similar to foldLeft but can be used as an operator with the order of list and zero arguments reversed. That is, z /: xs is the same as xs foldLeft z
Notes
Will not terminate for infinite-sized collections.
Overrides
Iterable./:

override def :\[B](z : B)(op : (A, B) => B) : B
An alias for foldRight. That is, xs :\ z is the same as xs foldRight z
Notes
Will not terminate for infinite-sized collections.
Overrides
Iterable.:\

override def reduceLeft[B >: A](op : (B, A) => B) : B
Combines the elements of this iterable object together using the binary operator op, from left to right
Notes
Will not terminate for infinite-sized collections.
Parameters
op - The operator to apply
Returns
op(... op(a0,a1), ..., an) if the iterable object has elements a0, a1, ..., an.
Throws
Predef.UnsupportedOperationException - if the iterable object is empty.
Overrides
Iterable.reduceLeft

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.
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.
Overrides
Iterable.reduceRight

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

override def sameElements[B >: A](that : Iterable[B]) : Boolean
Checks if the other iterable object contains the same elements.
Notes
will not terminate for infinite-sized collections.
Parameters
that - the other iterable object
Returns
true, iff both iterable objects contain the same elements.
Overrides
Iterable.sameElements

override def toList : List[A]
Returns a list containing all of the elements in this iterable object.
Notes
Will not terminate for infinite-sized collections.
Overrides
Iterable.toList

override def toSeq : Seq[A]
Returns a sequence containing all of the elements in this iterable object.
Notes
Will not terminate for infinite-sized collections.
Overrides
Iterable.toSeq

override def toStream : Stream[A]
Returns a stream containing all of the elements in this iterable object.
Notes
consider using projection for lazy behavior.
Overrides
Iterable.toStream

override def mkString(start : java.lang.String, sep : java.lang.String, end : java.lang.String) : java.lang.String
Returns a string representation of this iterable 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)"
Notes
Will not terminate for infinite-sized collections.
Parameters
start - starting string.
sep - separator string.
end - ending string.
Returns
a string representation of this iterable object.
Overrides
Iterable.mkString

override def mkString(sep : java.lang.String) : java.lang.String
Returns a string representation of this iterable object. The string representations of elements (w.r.t. the method toString()) are separated by the string sep.
Notes
Will not terminate for infinite-sized collections.
Parameters
sep - separator string.
Returns
a string representation of this iterable object.
Overrides
Iterable.mkString

override def mkString : java.lang.String
Converts a collection into a flat String by each element's toString method.
Notes
Will not terminate for infinite-sized collections.
Overrides
Iterable.mkString

override def addString(buf : StringBuilder, start : java.lang.String, sep : java.lang.String, end : java.lang.String) : StringBuilder
Write all elements of this string into given string builder.
Notes
Will not terminate for infinite-sized collections.
Parameters
buf - the StringBuilder to which elements are appended
start - starting string.
sep - separator string.
end - ending string.
Returns
the buf StringBuilder object
Overrides
Iterable.addString

override def addString(buf : StringBuilder, sep : java.lang.String) : StringBuilder
Write all elements of this string into given string builder.
Notes
Will not terminate for infinite-sized collections.
Parameters
buf - the StringBuilder to which elements are appended
sep - separator string.
Returns
the buf StringBuilder object
Overrides
Iterable.addString

override def addString(buf : StringBuilder) : StringBuilder
Write all elements of this string into given string builder, with no separator string between elements.
Notes
Will not terminate for infinite-sized collections.
Parameters
buf - the StringBuilder to which elements are appended
Returns
the buf StringBuilder object
Overrides
Iterable.addString

override def copyToArray[B >: A](xs : Array[B], start : Int) : Unit
Fills the given array xs with the elements of this sequence starting at position start.
Notes
Will not terminate for infinite-sized collections.
Parameters
xs - the array to fill.
start - starting index.
Precondition
the array must be large enough to hold all elements.
Overrides
Iterable.copyToArray

override def isEmpty : Boolean
Is this collection empty?
Overrides
Iterable.isEmpty

override def projection : Projection[A]
returns a projection that can be used to call non-strict filter, map, and flatMap methods that build projections of the collection.
Overrides
Iterable.projection

override def hasDefiniteSize : Boolean
returns true iff this collection has a bound size. Many APIs in this trait will not work on collections of unbound sizes.
Overrides
Iterable.hasDefiniteSize