scala.collection

object Iterator

[source: scala/collection/Iterator.scala]

object Iterator
extends AnyRef
The Iterator object provides various functions for creating specialized iterators.
Author
Martin Odersky
Matthias Zenger
Version
2.8
Value Summary
val empty : Iterator[Nothing]
Method Summary
def apply [A](elems : A*) : Iterator[A]
Creates an iterator with given elements
def concat [A](xss : Iterator[A]*) : Iterator[A]
Concatenates the given argument iterators into a single iterator.
def fill [A](len : Int)(elem : => A) : Iterator[A]
An iterator that returns the results of some element computation a number of times.
def flatten [T](its : Iterator[Iterator[T]]) : Iterator[T]
Create an iterator that is the concantenation of all iterators returned by a given iterator of iterators.
def from (start : Int) : Iterator[Int]
An infinite-length iterator which returns successive values from some start value.
def from (start : Int, step : (Int) => Int) : Iterator[Int]
Create an iterator with elements en+1 = step(en) where e0 = start.
def from (start : Int, step : Int) : Iterator[Int]
An infinite-length iterator returning values equally spaced apart.
def fromArray [a](xs : Array[a]) : Iterator[a]
def fromArray [a](xs : Array[a], start : Int, length : Int) : Iterator[a]
def fromProduct (n : Product) : Iterator[Any]
def fromString (str : java.lang.String) : Iterator[Char]
def fromValues [a](xs : a*) : Iterator[a]
def iterate (start : Int, len : Int)(f : (Int) => Int) : Iterator[Int]
An iterator that repeatedly applies a given function to a start value.
def iterate (start : Int)(f : (Int) => Int) : Iterator[Int]
An infinite iterator that repeatedly applies a given function to a start value.
implicit def iteratorIteratorWrapper [A](its : Iterator[Iterator[A]]) : IteratorIteratorOps[A]
An implicit conversion which adds the `flatten` method to class `Iterator`
def range (start : Int, end : Int) : Iterator[Int]
An iterator returning successive values in some integer interval.
def range (start : Int, end : Int, step : (Int) => Int) : Iterator[Int]
Create an iterator with elements en+1 = step(en) where e0 = start and elements are in the range between start (inclusive) and end (exclusive)
def range (start : Int, end : Int, step : Int) : Iterator[Int]
An iterator returning equally spaced values in some integer interval.
def single [A](elem : A) : Iterator[A]
An iterator with a single element.
def tabulate [A](end : Int)(f : (Int) => A) : Iterator[A]
An iterator that returns values of a given function over a range of integer values starting from 0.
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Class Summary
class IteratorIteratorOps [A](its : Iterator[Iterator[A]]) extends AnyRef
A wrapper class for the `flatten `method that is added to class Iterator with implicit conversion @see iteratorIteratorWrapper.
Value Details
val empty : Iterator[Nothing]

Method Details
def single[A](elem : A) : Iterator[A]
An iterator with a single element.
Parameters
elem - the element
Notes
Equivalent, but more efficient than Iterator(elem)

def apply[A](elems : A*) : Iterator[A]
Creates an iterator with given elements
Parameters
elems - The elements returned one-by-one from the iterator

@deprecated

def concat[A](xss : Iterator[A]*) : Iterator[A]
Concatenates the given argument iterators into a single iterator.
Parameters
its - the argument iterators that are to be concatenated
Returns
the concatenation of all the argument iterators

def fill[A](len : Int)(elem : => A) : Iterator[A]
An iterator that returns the results of some element computation a number of times.
Parameters
len - The number of elements returned
elem - The element computation determinining each result

def tabulate[A](end : Int)(f : (Int) => A) : Iterator[A]
An iterator that returns values of a given function over a range of integer values starting from 0.
Parameters
end - The argument up to which values are tabulated.
f - The function computing the results
Returns
An iterator with values `f(0) ... f(end-1)`

def range(start : Int, end : Int) : Iterator[Int]
An iterator returning successive values in some integer interval.
Parameters
start - the start value of the iterator
end - the end value of the iterator (the first value NOT returned)
Returns
the iterator with values in range `start, start + 1, ..., end - 1`

def range(start : Int, end : Int, step : Int) : Iterator[Int]
An iterator returning equally spaced values in some integer interval.
Parameters
start - the start value of the iterator
end - the end value of the iterator (the first value NOT returned)
step - the increment value of the iterator (must be positive or negative)
Returns
the iterator with values in `start, start + step, ...` up to, but excluding `end`

def iterate(start : Int, len : Int)(f : (Int) => Int) : Iterator[Int]
An iterator that repeatedly applies a given function to a start value.
Parameters
start - the start value of the iterator
len - the number of elements returned by the iterator
f - the function that's repeatedly applied
Returns
the iterator returning `len` values in the sequence `start, f(start), f(f(start)), ...`

def iterate(start : Int)(f : (Int) => Int) : Iterator[Int]
An infinite iterator that repeatedly applies a given function to a start value.
Parameters
start - the start value of the iterator
f - the function that's repeatedly applied
Returns
the iterator returning the infinite sequence of values `start, f(start), f(f(start)), ...`

def from(start : Int) : Iterator[Int]
An infinite-length iterator which returns successive values from some start value.
Parameters
start - the start value of the iterator
Returns
the iterator returning the infinite sequence of values `start, start + 1, start + 2, ...`

def from(start : Int, step : Int) : Iterator[Int]
An infinite-length iterator returning values equally spaced apart.
Parameters
start - the start value of the iterator
step - the increment between successive values
Returns
the iterator returning the infinite sequence of values `start, start + 1 * step, start + 2 * step, ...`

implicit def iteratorIteratorWrapper[A](its : Iterator[Iterator[A]]) : IteratorIteratorOps[A]
An implicit conversion which adds the `flatten` method to class `Iterator`

@deprecated("use `xs.iterator' or `Iterator(xs)' instead")

def fromValues[a](xs : a*) : Iterator[a]

@deprecated("use `xs.iterator' instead")

def fromArray[a](xs : Array[a]) : Iterator[a]
Parameters
xs - the array of elements
See Also
also: Vector.iterator and slice

@deprecated("use `xs.slice(start, start + length).iterator' instead")

def fromArray[a](xs : Array[a], start : Int, length : Int) : Iterator[a]
Parameters
xs - the array of elements
start - the start index
length - the length
See Also
also: Vector.iterator and slice

@deprecated("replaced by <code>str.iterator</code>")

def fromString(str : java.lang.String) : Iterator[Char]
Parameters
str - the given string
Returns
the iterator on str

@deprecated("use product.productIterator instead")

def fromProduct(n : Product) : Iterator[Any]
Parameters
n - the product arity
Returns
the iterator on Product<n>.

@deprecated("use Iterator.iterate(start, end - start)(step) instead")

def range(start : Int, end : Int, step : (Int) => Int) : Iterator[Int]
Create an iterator with elements en+1 = step(en) where e0 = start and elements are in the range between start (inclusive) and end (exclusive)
Parameters
start - the start value of the iterator
end - the end value of the iterator
step - the increment function of the iterator, must be monotonically increasing or decreasing
Returns
the iterator with values in range [start;end).

@deprecated("use iterate(start)(step) instead")

def from(start : Int, step : (Int) => Int) : Iterator[Int]
Create an iterator with elements en+1 = step(en) where e0 = start.
Parameters
start - the start value of the iterator
step - the increment function of the iterator
Returns
the iterator starting at value start.

@deprecated("use its.flatten instead")

def flatten[T](its : Iterator[Iterator[T]]) : Iterator[T]
Create an iterator that is the concantenation of all iterators returned by a given iterator of iterators.
Parameters
its - The iterator which returns on each call to next a new iterator whose elements are to be concatenated to the result.