scala.Iterable

trait Iterable

trait Iterable[+ A]

 extends ScalaObject


Collection classes mixing in this class provide a method elements which returns an iterator over all the elements contained in the collection.
author
- Matthias Zenger
note
- If a collection has a known size, it should also sub-type Collection. Only potentially unbounded collections should directly sub-class Iterable.
version
- 1.1, 04/02/2004


Companion: Iterable

Source: Iterable.scala(114)

Direct Known Subclasses

Scope, Ranged, IterableProxy, Projection, Collection,

 Fields

elements abstract def elements
Creates a new iterator over all elements contained in this object [details]
return
- the new iterator
Iterator[A]
hasDefiniteSize def hasDefiniteSize
returns true iff this collection has a bound size [details]
Many APIs in this trait will not work on collections of unbound sizes.
Boolean
isEmpty def isEmpty
Is this collection empty?
Boolean
mkString def mkString
Converts a collection into a flat String by each element's toString method [details]
note
- Will not terminate for infinite-sized collections.
String
projection def projection
returns a projection that can be used to call non-strict filter, map, and flatMap methods that build projections of the collection
Projection[A]
toList def toList
Returns a list containing all of the elements in this iterable object [details]
note
- Will not terminate for infinite-sized collections.
List[A]
toSeq def toSeq
Returns a sequence containing all of the elements in this iterable object [details]
note
- Will not terminate for infinite-sized collections.
Seq[A]
toStream def toStream
Returns a stream containing all of the elements in this iterable object [details]
note
- consider using projection for lazy behavior.
Stream[A]

 Methods

!= final def !=(arg0 : Object) Boolean AnyRef
!= final def !=(arg0 : Any) Boolean Any
++ def ++[B >: A](that : Iterable[B])
Appends two iterable objects [details]
note
- Will not terminate for infinite-sized collections.
return
- the new iterable object
Collection[B]
/: def /:[B](z : B)(op : (B, A) => B)
Similar to foldLeft but can be used as an operator with the order of list and zero arguments reversed [details]
That is, z /: xs is the same as xs foldLeft z
note
- Will not terminate for infinite-sized collections.
B
:\ def :\[B](z : B)(op : (A, B) => B)
An alias for foldRight [details]
That is, xs :\ z is the same as xs foldRight z
note
- Will not terminate for infinite-sized collections.
B
== final def ==(arg0 : Any) Boolean Any
== final def ==(arg0 : Object) Boolean AnyRef
addString def addString(buf : StringBuilder, sep : String) StringBuilder
addString def addString(buf : StringBuilder, start : String, sep : String, end : String)
Write all elements of this string into given string builder [details]
note
- Will not terminate for infinite-sized collections.
param
buf - ...
return
- ...
StringBuilder
asInstanceOf final def asInstanceOf[T0] T0 Any
clone protected def clone Object AnyRef
concat def concat[B >: A](that : Iterable[B])
Appends two iterable objects [details]
deprecated
- use ++ instead
note
- Will not terminate for infinite-sized collections.
return
- the new iterable object
Collection[B]
copyToArray def copyToArray[B >: A](xs : Array[B], start : Int)
Fills the given array xs with the elements of this sequence starting at position start [details]
note
- Will not terminate for infinite-sized collections.
param
xs - the array to fill.
start - starting index.
pre
- the array must be large enough to hold all elements.
Unit
copyToBuffer def copyToBuffer[B >: A](dest : Buffer[B])
Copy all elements to a given buffer [details]
note
- Will not terminate if not finite.
- Will not terminate for infinite-sized collections.
param
dest - The buffer to which elements are copied
Unit
drop def drop(n : Int)
Returns this iterable without its n first elements If this iterable has less than n elements, the empty iterable is returned [details]
deprecated
- API does not make sense for non-ordered collections
note
- Will not terminate for infinite-sized collections.
param
n - the number of elements to drop
return
- the new iterable
Collection[A]
dropWhile def dropWhile(p : (A) => Boolean)
Returns the longest suffix of this iterable whose first element does not satisfy the predicate p [details]
note
- May not terminate for infinite-sized collections.
param
p - the test predicate.
return
- the longest suffix of the iterable whose first element does not satisfy the predicate p.
Collection[A]
eq final def eq(arg0 : Object) Boolean AnyRef
equals def equals(arg0 : Any) Boolean AnyRef
exists def exists(p : (A) => 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 [details]
note
- May not terminate for infinite-sized collections.
param
p - the predicate
return
- true, iff the predicate yields true for at least one element.
Boolean
filter def filter(p : (A) => Boolean)
Returns all the elements of this iterable that satisfy the predicate p [details]
The order of the elements is preserved.
note
- Will not terminate for infinite-sized collections.
param
p - the predicate used to filter the list.
return
- the elements of this list satisfying p.
Iterable[A]
finalize protected def finalize Unit AnyRef
find def find(p : (A) => Boolean)
Find and return the first element of the iterable object satisfying a predicate, if any [details]
note
- may not terminate for infinite-sized collections.
param
p - the predicate
return
- the first element in the iterable object satisfying p, or None if none exists.
Option[A]
findIndexOf def findIndexOf(p : (A) => Boolean)
Returns index of the first element satisying a predicate, or -1 [details]
note
- may not terminate for infinite-sized collections.
param
p - the predicate
return
- the index of the first element satisfying p, or -1 if such an element does not exist
Int
flatMap def flatMap[B](f : (A) => Iterable[B])
Applies the given function f to each element of this iterable, then concatenates the results [details]
note
- Will not terminate for infinite-sized collections.
param
f - the function to apply on each element.
return
- f(a0) ::: ... ::: f(an) if this iterable is a0, ..., an.
Iterable[B]
foldLeft def foldLeft[B](z : B)(op : (B, A) => B)
Combines the elements of this iterable object together using the binary function f, from left to right, and starting with the value z [details]
note
- Will not terminate for infinite-sized collections.
return
- f(... (f(f(z, a0), a1) ...), an) if the list is [a0, a1, ..., an].
B
foldRight def foldRight[B](z : B)(op : (A, B) => B)
Combines the elements of this list together using the binary function f, from right to left, and starting with the value z [details]
note
- Will not terminate for infinite-sized collections.
return
- f(a0, f(a1, f(..., f(an, z)...))) if the list is [a0, a1, ..., an].
B
forall def forall(p : (A) => Boolean)
Apply a predicate p to all elements of this iterable object and return true, iff the predicate yields true for all elements [details]
note
- May not terminate for infinite-sized collections.
param
p - the predicate
return
- true, iff the predicate yields true for all elements.
Boolean
foreach def foreach(f : (A) => Unit)
Apply a function f to all elements of this iterable object [details]
note
- Will not terminate for infinite-sized collections.
param
f - a function that is applied to every element.
Unit
getClass final def getClass Class[Any] AnyRef
hashCode def hashCode Int AnyRef
indexOf def indexOf[B >: A](elem : B)
Returns the index of the first occurence of the specified object in this iterable object [details]
note
- may not terminate for infinite-sized collections.
param
elem - element to search for.
return
- the index in this sequence of the first occurence of the specified element, or -1 if the sequence does not contain this element.
Int
isInstanceOf final def isInstanceOf[T0] Boolean Any
map def map[B](f : (A) => B)
Returns the iterable resulting from applying the given function f to each element of this iterable [details]
note
- Will not terminate for infinite-sized collections.
param
f - function to apply to each element.
return
- f(a0), ..., f(an) if this iterable is a0, ..., an.
Iterable[B]
mkString def mkString(sep : String)
Returns a string representation of this iterable object [details]
The string representations of elements (w.r.t. the method toString()) are separated by the string sep.
note
- Will not terminate for infinite-sized collections.
param
sep - separator string.
return
- a string representation of this iterable object.
String
mkString def mkString(start : String, sep : String, end : String)
Returns a string representation of this iterable object [details]
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.
ex
- List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"
note
- Will not terminate for infinite-sized collections.
param
sep - separator string.
start - starting string.
end - ending string.
return
- a string representation of this iterable object.
String
ne final def ne(arg0 : Object) Boolean AnyRef
notify final def notify Unit AnyRef
notifyAll final def notifyAll Unit AnyRef
partition def partition(p : (A) => Boolean)
Partitions this iterable in two iterables according to a predicate [details]
param
p - the predicate on which to partition
return
- 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.
(Iterable[A], Iterable[A])
reduceLeft def reduceLeft[B >: A](op : (B, A) => B)
Combines the elements of this iterable object together using the binary operator op, from left to right [details]
note
- Will not terminate for infinite-sized collections.
param
op - The operator to apply
return
- op(... op(a0,a1), ..., an) if the iterable object has elements a0, a1, ..., an.
throws
Predef.UnsupportedOperationException - if the iterable object is empty.
B
reduceRight def reduceRight[B >: A](op : (A, B) => B)
Combines the elements of this iterable object together using the binary operator op, from right to left [details]
note
- Will not terminate for infinite-sized collections.
param
op - The operator to apply
return
- a0 op (... op (an-1 op an)...) if the iterable object has elements a0, a1, ..., an.
throws
Predef.UnsupportedOperationException - if the iterator is empty.
B
sameElements def sameElements[B >: A](that : Iterable[B])
Checks if the other iterable object contains the same elements [details]
note
- will not terminate for infinite-sized collections.
param
that - the other iterable object
return
- true, iff both iterable objects contain the same elements.
Boolean
synchronized final def synchronized[T0](arg0 : T0) T0 AnyRef
take def take(n : Int)
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 [details]
deprecated
- API does not make sense for non-ordered collections
param
n - the number of elements to take
return
- the new iterable
Collection[A]
takeWhile def takeWhile(p : (A) => Boolean)
Returns the longest prefix of this iterable whose elements satisfy the predicate p [details]
note
- May not terminate for infinite-sized collections.
param
p - the test predicate.
return
- the longest prefix of this iterable whose elements satisfy the predicate p.
Iterable[A]
toString def toString String AnyRef
wait final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
wait final def wait Unit AnyRef
wait final def wait(arg0 : Long) Unit AnyRef
Copyright (c) 2008. All Rights Reserved.