in scala
class Iterator

mixin abstract `class` Iterator [ A ]
  `extends` java.lang.Object
  `with` scala.ScalaObject

  Iterators are data structures that allow to iterate over a sequence of elements. They have a `hasNext` method for checking if there is a next element available, and a `next` method which returns the next element and discards it from the iterator.

author:
  Martin Odersky
author:
  Matthias Zenger
version:
  1.2, 15/03/2004

Def Summary
| `def` /: [ B ] ( z : B ) ( f : (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`
| `def` :\ [ B ] ( z : B ) ( f : (A, B) => B ) : B An alias for `foldRight`. That is, `xs :\ z` is the same as `xs foldRight z`
| `def` append [ A <: B ] ( that : scala.Iterator[B] ) : java.lang.Object with scala.Iterator[B] Returns a new iterator that first yields the elements of this iterator followed by the elements provided by iterator `that`.
| `def` buffered : scala.BufferedIterator[A] Returns a buffered iterator from this iterator.
| `def` contains ( elem : scala.Any ) : scala.Boolean Tests if the given value `elem` is a member of this list.
| `def` copyToArray [ A <: B ] ( xs : scala.Array[B] , start : scala.Int ) : scala.Array[B] Fills the given array `xs` with the elements of this sequence starting at position `start`.
| `def` counted : java.lang.Object with scala.CountedIterator[A] Returns a counted iterator from this iterator.
| `def` drop ( n : scala.Int ) : scala.Iterator[A] Removes the first `n` elements from this iterator.
| `def` duplicate : scala.Tuple2[scala.Iterator[A],scala.Iterator[A]] Creates two new iterators that both iterate over the same elements than this iterator (in the same order).
| `def` exists ( p : (A) => scala.Boolean ) : scala.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.
| `def` filter ( p : (A) => scala.Boolean ) : scala.Iterator[A] Returns an iterator over all the elements of this iterator that satisfy the predicate `p`. The order of the elements is preserved.
| `def` find ( p : (A) => scala.Boolean ) : scala.Option[A] Find and return the first element of the iterable object satisfying a predicate, if any.
| `def` flatMap [ B ] ( f : (A) => scala.Iterator[B] ) : scala.Iterator[B] Applies the given function `f` to each element of this iterator, then concatenates the results.
| `def` foldLeft [ B ] ( z : B ) ( op : (B, A) => B ) : B Combines the elements of this list together using the binary operator `op`, from left to right, and starting with the value `z`.
| `def` foldRight [ B ] ( z : B ) ( op : (A, B) => B ) : B Combines the elements of this list together using the binary operator `op`, from rigth to left, and starting with the value `z`.
| `def` forall ( p : (A) => scala.Boolean ) : scala.Boolean Apply a predicate `p` to all elements of this iterable object and return true, iff the predicate yields true for all elements.
| `def` foreach ( f : (A) => scala.Unit ) : scala.Unit Apply a function `f` to all elements of this iterable object.
| `def` hasNext : scala.Boolean Does this iterator provide another element?
| `def` map [ B ] ( f : (A) => B ) : scala.Iterator[B] Returns a new iterator that maps all elements of this iterator to new elements using function `f`.
| `def` next : A Returns the next element.
| `def` take ( n : scala.Int ) : java.lang.Object with scala.Iterator[A] Returns a new iterator that iterates only over the first `n` elements.
| `def` toList : scala.List[A] Transform this iterator into a list of all elements.
| `def` zip [ B ] ( that : scala.Iterator[B] ) : java.lang.Object with scala.Iterator[scala.Tuple2[A,B]] Return an iterator formed from this iterator and the specified iterator `that` by associating each element of the former with the element at the same position in the latter.
| `def` zipWithIndex : java.lang.Object with scala.Iterator[scala.Tuple2[A,scala.Int]] Return an iterator that pairs each element of this iterator with its index, counting from 0.

Def Detail

`def` /: [ B ]( z : B ) ( f : (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`

`def` :\ [ B ]( z : B ) ( f : (A, B) => B ) : B

  An alias for `foldRight`. That is, `xs :\ z` is the same as `xs foldRight z`

`def` append [ A <: B ]( that : scala.Iterator[B] ) : java.lang.Object with scala.Iterator[B]

  Returns a new iterator that first yields the elements of this iterator followed by the elements provided by iterator `that`.

`def` buffered : scala.BufferedIterator[A]

  Returns a buffered iterator from this iterator.

`def` contains ( elem : scala.Any ) : scala.Boolean

  Tests if the given value `elem` is a member of this list.

param:
  elem element whose membership has to be tested.
return:
  True iff there is an element of this list which is equal (w.r.t. `==`) to `elem`.

`def` copyToArray [ A <: B ]( xs : scala.Array[B] , start : scala.Int ) : scala.Array[B]

  Fills the given array `xs` with the elements of this sequence starting at position `start`.

param:
  xs the array to fill.
param:
  start starting index.
return:
  the given array `xs` filled with the elements of this iterator.
pre:
  The array must be large enough to hold all elements.

`def` counted : java.lang.Object with scala.CountedIterator[A]

  Returns a counted iterator from this iterator.

`def` drop ( n : scala.Int ) : scala.Iterator[A]

  Removes the first `n` elements from this iterator.

`def` duplicate : scala.Tuple2[scala.Iterator[A],scala.Iterator[A]]

  Creates two new iterators that both iterate over the same elements than this iterator (in the same order).

`def` exists ( p : (A) => scala.Boolean ) : scala.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.

param:
  p the predicate
returns:
  true, iff the predicate yields true for at least one element.

`def` filter ( p : (A) => scala.Boolean ) : scala.Iterator[A]

  Returns an iterator over all the elements of this iterator that satisfy the predicate `p`. The order of the elements is preserved.

param:
  p the predicate used to filter the iterator.
return:
  the elements of this iterator satisfying `p`.

`def` find ( p : (A) => scala.Boolean ) : scala.Option[A]

  Find and return the first element of the iterable object satisfying a predicate, if any.

param:
  p the predicate
return:
  the first element in the iterable object satisfying `p`, or `None` if none exists.

`def` flatMap [ B ]( f : (A) => scala.Iterator[B] ) : scala.Iterator[B]

  Applies the given function `f` to each element of this iterator, then concatenates the results.

param:
  f the function to apply on each element.
return:
  an iterator over `f(a0), ... , f(an)` if this iterator yields the elements `a0, ..., an`.

`def` foldLeft [ B ]( z : B ) ( op : (B, A) => B ) : B

  Combines the elements of this list together using the binary operator `op`, from left to right, and starting with the value `z`.

return:
  `op(... (op(op(z,a0),a1) ...), an)` if the list is `List(a0, a1, ..., an)`.

`def` foldRight [ B ]( z : B ) ( op : (A, B) => B ) : B

  Combines the elements of this list together using the binary operator `op`, from rigth to left, and starting with the value `z`.

return:
  `a0 op (... op (an op z)...)` if the list is `[a0, a1, ..., an]`.

`def` forall ( p : (A) => scala.Boolean ) : scala.Boolean

  Apply a predicate `p` to all elements of this iterable object and return true, iff the predicate yields true for all elements.

param:
  p the predicate
returns:
  true, iff the predicate yields true for all elements.

`def` foreach ( f : (A) => scala.Unit ) : scala.Unit

  Apply a function `f` to all elements of this iterable object.

param:
  f a function that is applied to every element.

`def` hasNext : scala.Boolean

  Does this iterator provide another element?

`def` map [ B ]( f : (A) => B ) : scala.Iterator[B]

  Returns a new iterator that maps all elements of this iterator to new elements using function `f`.

`def` next : A

  Returns the next element.

`def` take ( n : scala.Int ) : java.lang.Object with scala.Iterator[A]

  Returns a new iterator that iterates only over the first `n` elements.

`def` toList : scala.List[A]

  Transform this iterator into a list of all elements.

return:
  a list which enumerates all elements of this iterator.

`def` zip [ B ]( that : scala.Iterator[B] ) : java.lang.Object with scala.Iterator[scala.Tuple2[A,B]]

  Return an iterator formed from this iterator and the specified iterator `that` by associating each element of the former with the element at the same position in the latter.

param:
  `that` must have the same number of elements as this iterator.
return:
  an iterator yielding `(a0,b0), ..., (an,bn)` where `ai` are the elements from this iterator and `bi` are the elements from iterator `that`.

`def` zipWithIndex : java.lang.Object with scala.Iterator[scala.Tuple2[A,scala.Int]]

  Return an iterator that pairs each element of this iterator with its index, counting from 0.

param:
  `start` the index of the first element
return:
  an iterator yielding `(a0,0), (a0,1)...` where `ai` are the elements from this iterator.