scala.collection

Iterator

trait Iterator [+A] extends TraversableOnce[A]

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.

Self Type
Iterator[A]
Source
Iterator.scala
Version

2.8

Since

1

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Iterator
  2. TraversableOnce
  3. GenTraversableOnce
  4. AnyRef
  5. Any
Visibility
  1. Public
  2. All

Type Members

  1. class GroupedIterator [B >: A] extends Iterator[Seq[B]]

    A flexible iterator for transforming an Iterator[A] into an Iterator[Seq[A]], with configurable sequence size, step, and strategy for dealing with elements which don't fit evenly.

Abstract Value Members

  1. def hasNext : Boolean

    Tests whether this iterator can provide another element.

    Tests whether this iterator can provide another element.

    returns

    true if a subsequent call to next will yield an element, false otherwise.

    Attributes
    abstract
  2. def next (): A

    Produces the next element of this iterator.

    Produces the next element of this iterator.

    returns

    the next element of this iterator, if hasNext is true, undefined behavior otherwise.

    Attributes
    abstract

Concrete Value Members

  1. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  2. def != (arg0: Any): Boolean

    Test two objects for inequality.

    Test two objects for inequality.

    returns

    true if !(this == that), false otherwise.

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Equivalent to x.hashCode except for boxed numeric types.

    Equivalent to x.hashCode except for boxed numeric types. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them.

    returns

    a hash value consistent with ==

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def ++ (that: ⇒ Iterator[A]): Iterator[A]

    [use case] Concatenates this iterator with another.

    [use case]

    Concatenates this iterator with another.

    that

    the other iterator

    returns

    a new iterator that first yields the values produced by this iterator followed by the values produced by iterator that.

    Attributes
    abstract
  5. def ++ [B >: A] (that: ⇒ GenTraversableOnce[B]): Iterator[B]

    Concatenates this iterator with another.

    Concatenates this iterator with another.

    that

    the other iterator

    returns

    a new iterator that first yields the values produced by this iterator followed by the values produced by iterator that.

  6. def /: [B] (z: B)(op: (B, A) ⇒ B): B

    Applies a binary operator to a start value and all elements of this traversable or iterator, going left to right.

    Applies a binary operator to a start value and all elements of this traversable or iterator, going left to right.

    Note: /: is alternate syntax for foldLeft; z /: xs is the same as xs foldLeft z.

    Note: will not terminate for infinite iterators.

    Note: might return different results for different runs, unless the underlying collection type is ordered or the operator is associative and commutative.

    B

    the result type of the binary operator.

    z

    the start value.

    op

    the binary operator.

    returns

    the result of inserting op between consecutive elements of this traversable or iterator, going left to right with the start value z on the left:

                op(...op(op(z, x,,1,,), x,,2,,), ..., x,,n,,)
    

    where x,,1,,, ..., x,,n,, are the elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  7. def /:\ [A1 >: A] (z: A1)(op: (A1, A1) ⇒ A1): A1

    A syntactic sugar for out of order folding.

    A syntactic sugar for out of order folding. See fold.

    Definition Classes
    GenTraversableOnce
  8. def :\ [B] (z: B)(op: (A, B) ⇒ B): B

    Applies a binary operator to all elements of this traversable or iterator and a start value, going right to left.

    Applies a binary operator to all elements of this traversable or iterator and a start value, going right to left.

    Note: :\ is alternate syntax for foldRight; xs :\ z is the same as xs foldRight z.

    Note: will not terminate for infinite iterators.

    Note: might return different results for different runs, unless the underlying collection type is ordered or the operator is associative and commutative.

    B

    the result type of the binary operator.

    z

    the start value

    op

    the binary operator

    returns

    the result of inserting op between consecutive elements of this traversable or iterator, going right to left with the start value z on the right:

                op(x,,1,,, op(x,,2,,, ... op(x,,n,,, z)...))
    

    where x,,1,,, ..., x,,n,, are the elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  9. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  10. def == (arg0: Any): Boolean

    Test two objects for equality.

    Test two objects for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    Attributes
    final
    Definition Classes
    Any
  11. def addString (b: StringBuilder): StringBuilder

    Appends all elements of this traversable or iterator to a string builder.

    Appends all elements of this traversable or iterator to a string builder. The written text consists of the string representations (w.r.t. the method toString) of all elements of this traversable or iterator without any separator string.

    b

    the string builder to which elements are appended.

    returns

    the string builder b to which elements were appended.

    Definition Classes
    TraversableOnce
  12. def addString (b: StringBuilder, sep: String): StringBuilder

    Appends all elements of this traversable or iterator to a string builder using a separator string.

    Appends all elements of this traversable or iterator to a string builder using a separator string. The written text consists of the string representations (w.r.t. the method toString) of all elements of this traversable or iterator, separated by the string sep.

    b

    the string builder to which elements are appended.

    sep

    the separator string.

    returns

    the string builder b to which elements were appended.

    Definition Classes
    TraversableOnce
  13. def addString (b: StringBuilder, start: String, sep: String, end: String): StringBuilder

    Appends all elements of this traversable or iterator to a string builder using start, end, and separator strings.

    Appends all elements of this traversable or iterator to a string builder using start, end, and separator strings. The written text begins with the string start and ends with the string end. Inside, the string representations (w.r.t. the method toString) of all elements of this traversable or iterator are separated by the string sep.

    b

    the string builder to which elements are appended.

    start

    the starting string.

    sep

    the separator string.

    end

    the ending string.

    returns

    the string builder b to which elements were appended.

    Definition Classes
    TraversableOnce
  14. def aggregate [B] (z: B)(seqop: (B, A) ⇒ B, combop: (B, B) ⇒ B): B

    Aggregates the results of applying an operator to subsequent elements.

    Aggregates the results of applying an operator to subsequent elements.

    This is a more general form of fold and reduce. It has similar semantics, but does not require the result to be a supertype of the element type. It traverses the elements in different partitions sequentially, using seqop to update the result, and then applies combop to results from different partitions. The implementation of this operation may operate on an arbitrary number of collection partitions, so combop may be invoked arbitrary number of times.

    For example, one might want to process some elements and then produce a Set. In this case, seqop would process an element and append it to the list, while combop would concatenate two lists from different partitions together. The initial value z would be an empty set.

       pc.aggregate(Set[Int]())(_ += process(_), _ ++ _)
    

    Another example is calculating geometric mean from a collection of doubles (one would typically require big doubles for this).

    z

    the initial value for the accumulated result of the partition - this will typically be the neutral element for the seqop operator (e.g. Nil for list concatenation or 0 for summation)

    seqop

    an operator used to accumulate results within a partition

    combop

    an associative operator used to combine results from different partitions

    Definition Classes
    TraversableOnceGenTraversableOnce
  15. def asInstanceOf [T0] : T0

    Cast the receiver object to be of type T0.

    Cast the receiver object to be of type T0.

    Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression 1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expression List(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested type.

    returns

    the receiver object.

    Attributes
    final
    Definition Classes
    Any
  16. def buffered : BufferedIterator[A]

    Creates a buffered iterator from this iterator.

    Creates a buffered iterator from this iterator.

    returns

    a buffered iterator producing the same values as this iterator.

    See also

    BufferedIterator

  17. def clone (): AnyRef

    Create a copy of the receiver object.

    Create a copy of the receiver object.

    The default implementation of the clone method is platform dependent.

    returns

    a copy of the receiver object.

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  18. def collect [B] (pf: PartialFunction[A, B]): Iterator[B]

    Creates an iterator by transforming values produced by this iterator with a partial function, dropping those values for which the partial function is not defined.

    Creates an iterator by transforming values produced by this iterator with a partial function, dropping those values for which the partial function is not defined.

    pf

    the partial function which filters and maps the iterator.

    returns

    a new iterator which yields each value x produced by this iterator for which pf is defined the image pf(x).

    Annotations
    @migration
    Migration

    "This collect implementation bears no relationship to the one before 2.8.\n"+ "The previous behavior can be reproduced with toSeq."

  19. def collectFirst [B] (pf: PartialFunction[A, B]): Option[B]

    Finds the first element of the traversable or iterator for which the given partial function is defined, and applies the partial function to it.

    Finds the first element of the traversable or iterator for which the given partial function is defined, and applies the partial function to it.

    Note: may not terminate for infinite iterators.

    Note: might return different results for different runs, unless the underlying collection type is ordered.

    pf

    the partial function

    returns

    an option value containing pf applied to the first value for which it is defined, or None if none exists.

    Definition Classes
    TraversableOnce
    Example:
    1. Seq("a", 1, 5L).collectFirst({ case x: Int => x*10 }) = Some(10)

  20. def contains (elem: Any): Boolean

    Tests whether this iterator contains a given value as an element.

    Tests whether this iterator contains a given value as an element.

    Note: may not terminate for infinite iterators.

    elem

    the element to test.

    returns

    true if this iterator produces some value that is is equal (wrt ==) to elem, false otherwise.

  21. def copyToArray (xs: Array[A], start: Int, len: Int): Unit

    [use case] Copies selected values produced by this iterator to an array.

    [use case]

    Copies selected values produced by this iterator to an array. Fills the given array xs starting at index start with at most len values produced by this iterator. Copying will stop once either the end of the current iterator is reached, or the end of the array is reached, or len elements have been copied.

    xs

    the array to fill.

    start

    the starting index.

    len

    the maximal number of elements to copy.

    Attributes
    abstract
  22. def copyToArray [B >: A] (xs: Array[B], start: Int, len: Int): Unit

    Copies selected values produced by this iterator to an array.

    Copies selected values produced by this iterator to an array. Fills the given array xs starting at index start with at most len values produced by this iterator. Copying will stop once either the end of the current iterator is reached, or the end of the array is reached, or len elements have been copied.

    Note: will not terminate for infinite iterators.

    B

    the type of the elements of the array.

    xs

    the array to fill.

    start

    the starting index.

    len

    the maximal number of elements to copy.

    Definition Classes
    IteratorTraversableOnceGenTraversableOnce
  23. def copyToArray (xs: Array[A]): Unit

    [use case] Copies values of this traversable or iterator to an array.

    [use case]

    Copies values of this traversable or iterator to an array. Fills the given array xs with values of this traversable or iterator. Copying will stop once either the end of the current traversable or iterator is reached, or the end of the array is reached.

    xs

    the array to fill.

    Attributes
    abstract
    Definition Classes
    GenTraversableOnce
  24. def copyToArray [B >: A] (xs: Array[B]): Unit

    Copies values of this traversable or iterator to an array.

    Copies values of this traversable or iterator to an array. Fills the given array xs with values of this traversable or iterator. Copying will stop once either the end of the current traversable or iterator is reached, or the end of the array is reached.

    Note: will not terminate for infinite iterators.

    B

    the type of the elements of the array.

    xs

    the array to fill.

    Definition Classes
    TraversableOnceGenTraversableOnce
  25. def copyToArray (xs: Array[A], start: Int): Unit

    [use case] Copies values of this traversable or iterator to an array.

    [use case]

    Copies values of this traversable or iterator to an array. Fills the given array xs with values of this traversable or iterator, beginning at index start. Copying will stop once either the end of the current traversable or iterator is reached, or the end of the array is reached.

    xs

    the array to fill.

    start

    the starting index.

    Attributes
    abstract
    Definition Classes
    GenTraversableOnce
  26. def copyToArray [B >: A] (xs: Array[B], start: Int): Unit

    Copies values of this traversable or iterator to an array.

    Copies values of this traversable or iterator to an array. Fills the given array xs with values of this traversable or iterator, beginning at index start. Copying will stop once either the end of the current traversable or iterator is reached, or the end of the array is reached.

    Note: will not terminate for infinite iterators.

    B

    the type of the elements of the array.

    xs

    the array to fill.

    start

    the starting index.

    Definition Classes
    TraversableOnceGenTraversableOnce
  27. def copyToBuffer [B >: A] (dest: Buffer[B]): Unit

    Copies all elements of this traversable or iterator to a buffer.

    Copies all elements of this traversable or iterator to a buffer.

    Note: will not terminate for infinite iterators.

    dest

    The buffer to which elements are copied.

    Definition Classes
    TraversableOnce
  28. def count (p: (A) ⇒ Boolean): Int

    Counts the number of elements in the traversable or iterator which satisfy a predicate.

    Counts the number of elements in the traversable or iterator which satisfy a predicate.

    p

    the predicate used to test elements.

    returns

    the number of elements satisfying the predicate p.

    Definition Classes
    TraversableOnceGenTraversableOnce
  29. def drop (n: Int): Iterator[A]

    Advances this iterator past the first n elements, or the length of the iterator, whichever is smaller.

    Advances this iterator past the first n elements, or the length of the iterator, whichever is smaller.

    n

    the number of elements to drop

    returns

    an iterator which produces all values of the current iterator, except it omits the first n values.

  30. def dropWhile (p: (A) ⇒ Boolean): Iterator[A]

    Skips longest sequence of elements of this iterator which satisfy given predicate p, and returns an iterator of the remaining elements.

    Skips longest sequence of elements of this iterator which satisfy given predicate p, and returns an iterator of the remaining elements.

    p

    the predicate used to skip elements.

    returns

    an iterator consisting of the remaining elements

  31. def duplicate : (Iterator[A], Iterator[A])

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

    Creates two new iterators that both iterate over the same elements as this iterator (in the same order). The duplicate iterators are considered equal if they are positioned at the same element.

    returns

    a pair of iterators

  32. def eq (arg0: AnyRef): Boolean

    Tests whether the argument (arg0) is a reference to the receiver object (this).

    Tests whether the argument (arg0) is a reference to the receiver object (this).

    The eq method implements an equivalence relation on non-null instances of AnyRef, and has three additional properties:

    • It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false.
    • For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false.
    • null.eq(null) returns true.

    When overriding the equals or hashCode methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).

    returns

    true if the argument is a reference to the receiver object; false otherwise.

    Attributes
    final
    Definition Classes
    AnyRef
  33. def equals (arg0: Any): Boolean

    The equality method for reference types.

    The equality method for reference types. See equals in Any.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    Definition Classes
    AnyRef → Any
  34. def exists (p: (A) ⇒ Boolean): Boolean

    Tests whether a predicate holds for some of the values produced by this iterator.

    Tests whether a predicate holds for some of the values produced by this iterator.

    Note: may not terminate for infinite iterators.

    p

    the predicate used to test elements.

    returns

    true if the given predicate p holds for some of the values produced by this iterator, otherwise false.

    Definition Classes
    IteratorTraversableOnceGenTraversableOnce
  35. def filter (p: (A) ⇒ Boolean): Iterator[A]

    Returns an iterator over all the elements of this iterator that satisfy the predicate p.

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

    p

    the predicate used to test values.

    returns

    an iterator which produces those values of this iterator which satisfy the predicate p.

  36. def filterNot (p: (A) ⇒ Boolean): Iterator[A]

    Creates an iterator over all the elements of this iterator which do not satisfy a predicate p.

    Creates an iterator over all the elements of this iterator which do not satisfy a predicate p.

    p

    the predicate used to test values.

    returns

    an iterator which produces those values of this iterator which do not satisfy the predicate p.

  37. def finalize (): Unit

    Called by the garbage collector on the receiver object when there are no more references to the object.

    Called by the garbage collector on the receiver object when there are no more references to the object.

    The details of when and if the finalize method is invoked, as well as the interaction between finalize and non-local returns and exceptions, are all platform dependent.

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  38. def find (p: (A) ⇒ Boolean): Option[A]

    Finds the first value produced by the iterator satisfying a predicate, if any.

    Finds the first value produced by the iterator satisfying a predicate, if any.

    Note: may not terminate for infinite iterators.

    p

    the predicate used to test values.

    returns

    an option value containing the first value produced by the iterator that satisfies predicate p, or None if none exists.

    Definition Classes
    IteratorTraversableOnceGenTraversableOnce
  39. def flatMap [B] (f: (A) ⇒ GenTraversableOnce[B]): Iterator[B]

    Creates a new iterator by applying a function to all values produced by this iterator and concatenating the results.

    Creates a new iterator by applying a function to all values produced by this iterator and concatenating the results.

    f

    the function to apply on each element.

    returns

    the iterator resulting from applying the given iterator-valued function f to each value produced by this iterator and concatenating the results.

  40. def fold [A1 >: A] (z: A1)(op: (A1, A1) ⇒ A1): A1

    Folds the elements of this sequence using the specified associative binary operator.

    Folds the elements of this sequence using the specified associative binary operator. The order in which the elements are reduced is unspecified and may be nondeterministic.

    Note this method has a different signature than the foldLeft and foldRight methods of the trait Traversable. The result of folding may only be a supertype of this parallel collection's type parameter T.

    z

    a neutral element for the fold operation, it may be added to the result an arbitrary number of times, not changing the result (e.g. Nil for list concatenation, 0 for addition, or 1 for multiplication)

    op

    a binary operator that must be associative

    returns

    the result of applying fold operator op between all the elements and z

    Definition Classes
    TraversableOnceGenTraversableOnce
  41. def foldLeft [B] (z: B)(op: (B, A) ⇒ B): B

    Applies a binary operator to a start value and all elements of this traversable or iterator, going left to right.

    Applies a binary operator to a start value and all elements of this traversable or iterator, going left to right.

    Note: will not terminate for infinite iterators.

    Note: might return different results for different runs, unless the underlying collection type is ordered or the operator is associative and commutative.

    B

    the result type of the binary operator.

    z

    the start value.

    op

    the binary operator.

    returns

    the result of inserting op between consecutive elements of this traversable or iterator, going left to right with the start value z on the left:

                op(...op(z, x,,1,,), x,,2,,, ..., x,,n,,)
    

    where x,,1,,, ..., x,,n,, are the elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  42. def foldRight [B] (z: B)(op: (A, B) ⇒ B): B

    Applies a binary operator to all elements of this traversable or iterator and a start value, going right to left.

    Applies a binary operator to all elements of this traversable or iterator and a start value, going right to left.

    Note: will not terminate for infinite iterators.

    Note: might return different results for different runs, unless the underlying collection type is ordered or the operator is associative and commutative.

    B

    the result type of the binary operator.

    z

    the start value.

    op

    the binary operator.

    returns

    the result of inserting op between consecutive elements of this traversable or iterator, going right to left with the start value z on the right:

                op(x,,1,,, op(x,,2,,, ... op(x,,n,,, z)...))
    

    where x,,1,,, ..., x,,n,, are the elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  43. def forall (p: (A) ⇒ Boolean): Boolean

    Tests whether a predicate holds for all values produced by this iterator.

    Tests whether a predicate holds for all values produced by this iterator.

    Note: may not terminate for infinite iterators.

    p

    the predicate used to test elements.

    returns

    true if the given predicate p holds for all values produced by this iterator, otherwise false.

    Definition Classes
    IteratorTraversableOnceGenTraversableOnce
  44. def foreach (f: (A) ⇒ Unit): Unit

    [use case] Applies a function f to all values produced by this iterator.

    [use case]

    Applies a function f to all values produced by this iterator.

    f

    the function that is applied for its side-effect to every element. The result of function f is discarded.

    Attributes
    abstract
  45. def foreach [U] (f: (A) ⇒ U): Unit

    Applies a function f to all values produced by this iterator.

    Applies a function f to all values produced by this iterator.

    U

    the type parameter describing the result of function f. This result will always be ignored. Typically U is Unit, but this is not necessary.

    f

    the function that is applied for its side-effect to every element. The result of function f is discarded.

    Definition Classes
    IteratorTraversableOnceGenTraversableOnce
  46. def getClass (): java.lang.Class[_ <: java.lang.Object]

    A representation that corresponds to the dynamic class of the receiver object.

    A representation that corresponds to the dynamic class of the receiver object.

    The nature of the representation is platform dependent.

    returns

    a representation that corresponds to the dynamic class of the receiver object.

    Attributes
    final
    Definition Classes
    AnyRef
  47. def grouped [B >: A] (size: Int): GroupedIterator[B]

    Returns an iterator which groups this iterator into fixed size blocks.

    Returns an iterator which groups this iterator into fixed size blocks. Example usages:

       // Returns List(List(1, 2, 3), List(4, 5, 6), List(7)))
       (1 to 7).iterator grouped 3 toList
       // Returns List(List(1, 2, 3), List(4, 5, 6))
       (1 to 7).iterator grouped 3 withPartial false toList
       // Returns List(List(1, 2, 3), List(4, 5, 6), List(7, 20, 25)
       // Illustrating that withPadding's argument is by-name.
       val it2 = Iterator.iterate(20)(_ + 5)
       (1 to 7).iterator grouped 3 withPadding it2.next toList
    

  48. def hasDefiniteSize : Boolean

    Tests whether this Iterator has a known size.

    Tests whether this Iterator has a known size.

    returns

    true for empty Iterators, false otherwise.

    Definition Classes
    IteratorTraversableOnceGenTraversableOnce
  49. def hashCode (): Int

    The hashCode method for reference types.

    The hashCode method for reference types. See hashCode in Any.

    returns

    the hash code value for this object.

    Definition Classes
    AnyRef → Any
  50. def indexOf [B >: A] (elem: B): Int

    Returns the index of the first occurrence of the specified object in this iterable object.

    Returns the index of the first occurrence of the specified object in this iterable object.

    Note: may not terminate for infinite iterators.

    elem

    element to search for.

    returns

    the index of the first occurrence of elem in the values produced by this iterator, or -1 if such an element does not exist until the end of the iterator is reached.

  51. def indexWhere (p: (A) ⇒ Boolean): Int

    Returns the index of the first produced value satisfying a predicate, or -1.

    Returns the index of the first produced value satisfying a predicate, or -1.

    Note: may not terminate for infinite iterators.

    p

    the predicate to test values

    returns

    the index of the first produced value satisfying p, or -1 if such an element does not exist until the end of the iterator is reached.

  52. def isEmpty : Boolean

    Tests whether this iterator is empty.

    Tests whether this iterator is empty.

    returns

    true if hasNext is false, false otherwise.

    Definition Classes
    IteratorTraversableOnceGenTraversableOnce
  53. def isInstanceOf [T0] : Boolean

    Test whether the dynamic type of the receiver object is T0.

    Test whether the dynamic type of the receiver object is T0.

    Note that the result of the test is modulo Scala's erasure semantics. Therefore the expression 1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will return true. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the specified type.

    returns

    true if the receiver object is an instance of erasure of type T0; false otherwise.

    Attributes
    final
    Definition Classes
    Any
  54. def isTraversableAgain : Boolean

    Tests whether this Iterator can be repeatedly traversed.

    Tests whether this Iterator can be repeatedly traversed.

    returns

    false

    Definition Classes
    IteratorGenTraversableOnce
  55. def length : Int

    Returns the number of elements in this iterator.

    Returns the number of elements in this iterator.

    Note: will not terminate for infinite iterators.

    Note: The iterator is at its end after this method returns.

  56. def map [B] (f: (A) ⇒ B): Iterator[B]

    Creates a new iterator that maps all produced values of this iterator to new values using a transformation function.

    Creates a new iterator that maps all produced values of this iterator to new values using a transformation function.

    f

    the transformation function

    returns

    a new iterator which transforms every value produced by this iterator by applying the function f to it.

  57. def max : A

    [use case] Finds the largest element.

    [use case]

    Finds the largest element.

    returns

    the largest element of this traversable or iterator with respect to the ordering cmp.

    Attributes
    abstract
    Definition Classes
    GenTraversableOnce
  58. def max [B >: A] (implicit cmp: Ordering[B]): A

    Finds the largest element.

    Finds the largest element.

    B

    The type over which the ordering is defined.

    cmp

    An ordering to be used for comparing elements.

    returns

    the largest element of this traversable or iterator with respect to the ordering cmp.

    Definition Classes
    TraversableOnceGenTraversableOnce
  59. def maxBy [B] (f: (A) ⇒ B)(implicit cmp: Ordering[B]): A

    Definition Classes
    TraversableOnceGenTraversableOnce
  60. def min : A

    [use case] Finds the smallest element.

    [use case]

    Finds the smallest element.

    returns

    the smallest element of this traversable or iterator with respect to the ordering cmp.

    Attributes
    abstract
    Definition Classes
    GenTraversableOnce
  61. def min [B >: A] (implicit cmp: Ordering[B]): A

    Finds the smallest element.

    Finds the smallest element.

    B

    The type over which the ordering is defined.

    cmp

    An ordering to be used for comparing elements.

    returns

    the smallest element of this traversable or iterator with respect to the ordering cmp.

    Definition Classes
    TraversableOnceGenTraversableOnce
  62. def minBy [B] (f: (A) ⇒ B)(implicit cmp: Ordering[B]): A

    Definition Classes
    TraversableOnceGenTraversableOnce
  63. def mkString : String

    Displays all elements of this traversable or iterator in a string.

    Displays all elements of this traversable or iterator in a string.

    returns

    a string representation of this traversable or iterator. In the resulting string the string representations (w.r.t. the method toString) of all elements of this traversable or iterator follow each other without any separator string.

    Definition Classes
    TraversableOnceGenTraversableOnce
  64. def mkString (sep: String): String

    Displays all elements of this traversable or iterator in a string using a separator string.

    Displays all elements of this traversable or iterator in a string using a separator string.

    sep

    the separator string.

    returns

    a string representation of this traversable or iterator. In the resulting string the string representations (w.r.t. the method toString) of all elements of this traversable or iterator are separated by the string sep.

    Definition Classes
    TraversableOnceGenTraversableOnce
    Example:
    1. List(1, 2, 3).mkString("|") = "1|2|3"

  65. def mkString (start: String, sep: String, end: String): String

    Displays all elements of this traversable or iterator in a string using start, end, and separator strings.

    Displays all elements of this traversable or iterator in a string using start, end, and separator strings.

    start

    the starting string.

    sep

    the separator string.

    end

    the ending string.

    returns

    a string representation of this traversable or iterator. The resulting string begins with the string start and ends with the string end. Inside, the string representations (w.r.t. the method toString) of all elements of this traversable or iterator are separated by the string sep.

    Definition Classes
    TraversableOnceGenTraversableOnce
    Example:
    1. List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"

  66. def ne (arg0: AnyRef): Boolean

    Equivalent to !(this eq that).

    Equivalent to !(this eq that).

    returns

    true if the argument is not a reference to the receiver object; false otherwise.

    Attributes
    final
    Definition Classes
    AnyRef
  67. def nonEmpty : Boolean

    Tests whether the traversable or iterator is not empty.

    Tests whether the traversable or iterator is not empty.

    returns

    true if the traversable or iterator contains at least one element, false otherwise.

    Definition Classes
    TraversableOnceGenTraversableOnce
  68. def notify (): Unit

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Attributes
    final
    Definition Classes
    AnyRef
  69. def notifyAll (): Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

    Wakes up all threads that are waiting on the receiver object's monitor.

    Attributes
    final
    Definition Classes
    AnyRef
  70. def padTo (len: Int, elem: A): Iterator[A]

    [use case] Appends an element value to this iterator until a given target length is reached.

    [use case]

    Appends an element value to this iterator until a given target length is reached.

    len

    the target length

    elem

    the padding value

    returns

    a new iterator consisting of producing all values of this iterator, followed by the minimal number of occurrences of elem so that the number of produced values is at least len.

    Attributes
    abstract
  71. def padTo [A1 >: A] (len: Int, elem: A1): Iterator[A1]

    Appends an element value to this iterator until a given target length is reached.

    Appends an element value to this iterator until a given target length is reached.

    len

    the target length

    elem

    the padding value

    returns

    a new iterator consisting of producing all values of this iterator, followed by the minimal number of occurrences of elem so that the number of produced values is at least len.

  72. def partition (p: (A) ⇒ Boolean): (Iterator[A], Iterator[A])

    Partitions this iterator in two iterators according to a predicate.

    Partitions this iterator in two iterators according to a predicate.

    p

    the predicate on which to partition

    returns

    a pair of iterators: the iterator that satisfies the predicate p and the iterator that does not. The relative order of the elements in the resulting iterators is the same as in the original iterator.

  73. def patch [B >: A] (from: Int, patchElems: Iterator[B], replaced: Int): Iterator[B]

    Returns this iterator with patched values.

    Returns this iterator with patched values.

    from

    The start index from which to patch

    replaced

    The number of values in the original iterator that are replaced by the patch.

  74. def product : A

    [use case] Multiplies up the elements of this collection.

    [use case]

    Multiplies up the elements of this collection.

    returns

    the product of all elements of this traversable or iterator with respect to the * operator in num.

    Attributes
    abstract
    Definition Classes
    GenTraversableOnce
  75. def product [B >: A] (implicit num: Numeric[B]): B

    Multiplies up the elements of this collection.

    Multiplies up the elements of this collection.

    B

    the result type of the * operator.

    num

    an implicit parameter defining a set of numeric operations which includes the * operator to be used in forming the product.

    returns

    the product of all elements of this traversable or iterator with respect to the * operator in num.

    Definition Classes
    TraversableOnceGenTraversableOnce
  76. def reduce [A1 >: A] (op: (A1, A1) ⇒ A1): A1

    Reduces the elements of this sequence using the specified associative binary operator.

    Reduces the elements of this sequence using the specified associative binary operator.

    The order in which operations are performed on elements is unspecified and may be nondeterministic.

    Note this method has a different signature than the reduceLeft and reduceRight methods of the trait Traversable. The result of reducing may only be a supertype of this parallel collection's type parameter T.

    op

    A binary operator that must be associative.

    returns

    The result of applying reduce operator op between all the elements if the collection is nonempty.

    Definition Classes
    TraversableOnceGenTraversableOnce
  77. def reduceLeft [B >: A] (op: (B, A) ⇒ B): B

    Definition Classes
    TraversableOnce
  78. def reduceLeftOption [B >: A] (op: (B, A) ⇒ B): Option[B]

    Optionally applies a binary operator to all elements of this traversable or iterator, going left to right.

    Optionally applies a binary operator to all elements of this traversable or iterator, going left to right.

    Note: will not terminate for infinite iterators.

    Note: might return different results for different runs, unless the underlying collection type is ordered or the operator is associative and commutative.

    B

    the result type of the binary operator.

    op

    the binary operator.

    returns

    an option value containing the result of reduceLeft(op) is this traversable or iterator is nonempty, None otherwise.

    Definition Classes
    TraversableOnceGenTraversableOnce
  79. def reduceOption [A1 >: A] (op: (A1, A1) ⇒ A1): Option[A1]

    Optionally reduces the elements of this sequence using the specified associative binary operator.

    Optionally reduces the elements of this sequence using the specified associative binary operator.

    The order in which operations are performed on elements is unspecified and may be nondeterministic.

    Note this method has a different signature than the reduceLeftOption and reduceRightOption methods of the trait Traversable. The result of reducing may only be a supertype of this parallel collection's type parameter T.

    op

    A binary operator that must be associative.

    returns

    An option value containing result of applying reduce operator op between all the elements if the collection is nonempty, and None otherwise.

    Definition Classes
    TraversableOnceGenTraversableOnce
  80. def reduceRight [B >: A] (op: (A, B) ⇒ B): B

    Applies a binary operator to all elements of this traversable or iterator, going right to left.

    Applies a binary operator to all elements of this traversable or iterator, going right to left.

    Note: will not terminate for infinite iterators.

    Note: might return different results for different runs, unless the underlying collection type is ordered or the operator is associative and commutative.

    B

    the result type of the binary operator.

    op

    the binary operator.

    returns

    the result of inserting op between consecutive elements of this traversable or iterator, going right to left:

                op(x,,1,,, op(x,,2,,, ..., op(x,,n-1,,, x,,n,,)...))
    

    where x,,1,,, ..., x,,n,, are the elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  81. def reduceRightOption [B >: A] (op: (A, B) ⇒ B): Option[B]

    Optionally applies a binary operator to all elements of this traversable or iterator, going right to left.

    Optionally applies a binary operator to all elements of this traversable or iterator, going right to left.

    Note: will not terminate for infinite iterators.

    Note: might return different results for different runs, unless the underlying collection type is ordered or the operator is associative and commutative.

    B

    the result type of the binary operator.

    op

    the binary operator.

    returns

    an option value containing the result of reduceRight(op) is this traversable or iterator is nonempty, None otherwise.

    Definition Classes
    TraversableOnceGenTraversableOnce
  82. def reversed : List[A]

    Attributes
    protected[this]
    Definition Classes
    TraversableOnce
  83. def sameElements (that: Iterator[_]): Boolean

    Tests if another iterator produces the same values as this one.

    Tests if another iterator produces the same values as this one.

    Note: will not terminate for infinite iterators.

    that

    the other iterator

    returns

    true, if both iterators produce the same elements in the same order, false otherwise.

  84. def scanLeft [B] (z: B)(op: (B, A) ⇒ B): Iterator[B]

  85. def scanRight [B] (z: B)(op: (A, B) ⇒ B): Iterator[B]

  86. def seq : Iterator[A]

    A version of this collection with all of the operations implemented sequentially (i.

    A version of this collection with all of the operations implemented sequentially (i.e. in a single-threaded manner).

    This method returns a reference to this collection. In parallel collections, it is redefined to return a sequential implementation of this collection. In both cases, it has O(1) complexity.

    returns

    a sequential view of the collection.

    Definition Classes
    IteratorTraversableOnceGenTraversableOnce
  87. def size : Int

    The size of this traversable or iterator.

    The size of this traversable or iterator.

    Note: will not terminate for infinite iterators.

    returns

    the number of elements in this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  88. def slice (from: Int, until: Int): Iterator[A]

    Creates an iterator returning an interval of the values produced by this iterator.

    Creates an iterator returning an interval of the values produced by this iterator.

    from

    the index of the first element in this iterator which forms part of the slice.

    until

    the index of the first element following the slice.

    returns

    an iterator which advances this iterator past the first from elements using drop, and then takes until - from elements, using take.

  89. def sliding [B >: A] (size: Int, step: Int = 1): GroupedIterator[B]

    Returns an iterator which presents a "sliding window" view of another iterator.

    Returns an iterator which presents a "sliding window" view of another iterator. The first argument is the window size, and the second is how far to advance the window on each iteration; defaults to 1. Example usages:

       // Returns List(List(1, 2, 3), List(2, 3, 4), List(3, 4, 5))
       (1 to 5).iterator.sliding(3).toList
       // Returns List(List(1, 2, 3, 4), List(4, 5))
       (1 to 5).iterator.sliding(4, 3).toList
       // Returns List(List(1, 2, 3, 4))
       (1 to 5).iterator.sliding(4, 3).withPartial(false).toList
       // Returns List(List(1, 2, 3, 4), List(4, 5, 20, 25))
       // Illustrating that withPadding's argument is by-name.
       val it2 = Iterator.iterate(20)(_ + 5)
       (1 to 5).iterator.sliding(4, 3).withPadding(it2.next).toList
    

  90. def span (p: (A) ⇒ Boolean): (Iterator[A], Iterator[A])

    Splits this Iterator into a prefix/suffix pair according to a predicate.

    Splits this Iterator into a prefix/suffix pair according to a predicate.

    p

    the test predicate

    returns

    a pair of Iterators consisting of the longest prefix of this whose elements all satisfy p, and the rest of the Iterator.

  91. def sum : A

    [use case] Sums up the elements of this collection.

    [use case]

    Sums up the elements of this collection.

    returns

    the sum of all elements of this traversable or iterator with respect to the + operator in num.

    Attributes
    abstract
    Definition Classes
    GenTraversableOnce
  92. def sum [B >: A] (implicit num: Numeric[B]): B

    Sums up the elements of this collection.

    Sums up the elements of this collection.

    B

    the result type of the + operator.

    num

    an implicit parameter defining a set of numeric operations which includes the + operator to be used in forming the sum.

    returns

    the sum of all elements of this traversable or iterator with respect to the + operator in num.

    Definition Classes
    TraversableOnceGenTraversableOnce
  93. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  94. def take (n: Int): Iterator[A]

    Selects first n values of this iterator.

    Selects first n values of this iterator.

    n

    the number of values to take

    returns

    an iterator producing only of the first n values of this iterator, or else the whole iterator, if it produces fewer than n values.

  95. def takeWhile (p: (A) ⇒ Boolean): Iterator[A]

    Takes longest prefix of values produced by this iterator that satisfy a predicate.

    Takes longest prefix of values produced by this iterator that satisfy a predicate.

    p

    The predicate used to test elements.

    returns

    An iterator returning the values produced by this iterator, until this iterator produces a value that does not satisfy the predicate p.

  96. def toArray : Array[A]

    [use case] Converts this traversable or iterator to an array.

    [use case]

    Converts this traversable or iterator to an array.

    Note: will not terminate for infinite iterators.

    returns

    an array containing all elements of this traversable or iterator.

    Attributes
    abstract
    Definition Classes
    GenTraversableOnce
  97. def toArray [B >: A] (implicit arg0: ClassManifest[B]): Array[B]

    Converts this traversable or iterator to an array.

    Converts this traversable or iterator to an array.

    Note: will not terminate for infinite iterators.

    B

    the type of the elements of the array. A ClassManifest for this type must be available.

    returns

    an array containing all elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  98. def toBuffer [B >: A] : Buffer[B]

    Converts this traversable or iterator to a mutable buffer.

    Converts this traversable or iterator to a mutable buffer.

    Note: will not terminate for infinite iterators.

    returns

    a buffer containing all elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  99. def toIndexedSeq [B >: A] : IndexedSeq[B]

    Converts this traversable or iterator to an indexed sequence.

    Converts this traversable or iterator to an indexed sequence.

    Note: will not terminate for infinite iterators.

    returns

    an indexed sequence containing all elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  100. def toIterable : Iterable[A]

    Converts this traversable or iterator to an iterable collection.

    Converts this traversable or iterator to an iterable collection. Note that the choice of target Iterable is lazy in this default implementation as this TraversableOnce may be lazy and unevaluated (i.e. it may be an iterator which is only traversable once).

    Note: will not terminate for infinite iterators.

    returns

    an Iterable containing all elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  101. def toIterator : Iterator[A]

    Returns an Iterator over the elements in this traversable or iterator.

    Returns an Iterator over the elements in this traversable or iterator. Will return the same Iterator if this instance is already an Iterator.

    Note: will not terminate for infinite iterators.

    returns

    an Iterator containing all elements of this traversable or iterator.

    Definition Classes
    IteratorGenTraversableOnce
  102. def toList : List[A]

    Converts this traversable or iterator to a list.

    Converts this traversable or iterator to a list.

    Note: will not terminate for infinite iterators.

    returns

    a list containing all elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  103. def toMap [T, U] : Map[T, U]

    [use case] Converts this traversable or iterator to a map.

    [use case]

    Converts this traversable or iterator to a map. This method is unavailable unless the elements are members of Tuple2, each ((T, U)) becoming a key-value pair in the map. Duplicate keys will be overwritten by later keys: if this is an unordered collection, which key is in the resulting map is undefined.

    Note: will not terminate for infinite iterators.

    returns

    a map containing all elements of this traversable or iterator.

    Attributes
    abstract
    Definition Classes
    GenTraversableOnce
  104. def toMap [T, U] (implicit ev: <:<[A, (T, U)]): Map[T, U]

    Converts this traversable or iterator to a map.

    Converts this traversable or iterator to a map. This method is unavailable unless the elements are members of Tuple2, each ((T, U)) becoming a key-value pair in the map. Duplicate keys will be overwritten by later keys: if this is an unordered collection, which key is in the resulting map is undefined.

    Note: will not terminate for infinite iterators.

    returns

    a map containing all elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  105. def toSeq : Seq[A]

    Converts this traversable or iterator to a sequence.

    Converts this traversable or iterator to a sequence. As with toIterable, it's lazy in this default implementation, as this TraversableOnce may be lazy and unevaluated.

    Note: will not terminate for infinite iterators.

    returns

    a sequence containing all elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  106. def toSet [B >: A] : Set[B]

    Converts this traversable or iterator to a set.

    Converts this traversable or iterator to a set.

    Note: will not terminate for infinite iterators.

    returns

    a set containing all elements of this traversable or iterator.

    Definition Classes
    TraversableOnceGenTraversableOnce
  107. def toStream : Stream[A]

    Converts this traversable or iterator to a stream.

    Converts this traversable or iterator to a stream.

    Note: will not terminate for infinite iterators.

    returns

    a stream containing all elements of this traversable or iterator.

    Definition Classes
    IteratorGenTraversableOnce
  108. def toString (): String

    Converts this iterator to a string.

    Converts this iterator to a string.

    returns

    "empty iterator" or "non-empty iterator", depending on whether or not the iterator is empty.

    Definition Classes
    Iterator → AnyRef → Any
  109. def toTraversable : Traversable[A]

    Converts this traversable or iterator to an unspecified Traversable.

    Converts this traversable or iterator to an unspecified Traversable. Will return the same collection if this instance is already Traversable.

    Note: will not terminate for infinite iterators.

    returns

    a Traversable containing all elements of this traversable or iterator.

    Definition Classes
    IteratorTraversableOnceGenTraversableOnce
  110. def wait (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  111. def wait (arg0: Long, arg1: Int): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  112. def wait (arg0: Long): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  113. def withFilter (p: (A) ⇒ Boolean): Iterator[A]

    Creates an iterator over all the elements of this iterator that satisfy the predicate p.

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

    Note: withFilter is the same as filter on iterators. It exists so that for-expressions with filters work over iterators.

    p

    the predicate used to test values.

    returns

    an iterator which produces those values of this iterator which satisfy the predicate p.

  114. def zip [B] (that: Iterator[B]): Iterator[(A, B)]

    Creates an iterator formed from this iterator and another iterator by combining corresponding values in pairs.

    Creates an iterator formed from this iterator and another iterator by combining corresponding values in pairs. If one of the two iterators is longer than the other, its remaining elements are ignored.

    that

    The iterator providing the second half of each result pair

    returns

    a new iterator containing pairs consisting of corresponding elements of this iterator and that. The number of elements returned by the new iterator is the minimum of the number of elements returned by this iterator and that.

  115. def zipAll [B] (that: Iterator[B], thisElem: A, thatElem: B): Iterator[(A, B)]

    [use case] Creates an iterator formed from this iterator and another iterator by combining corresponding elements in pairs.

    [use case]

    Creates an iterator formed from this iterator and another iterator by combining corresponding elements in pairs. If one of the two iterators is shorter than the other, placeholder elements are used to extend the shorter iterator to the length of the longer.

    that

    iterator that may have a different length as the self iterator.

    thisElem

    element thisElem is used to fill up the resulting iterator if the self iterator is shorter than that

    thatElem

    element thatElem is used to fill up the resulting iterator if that is shorter than the self iterator

    returns

    a new iterator containing pairs consisting of corresponding values of this iterator and that. The length of the returned iterator is the maximum of the lengths of this iterator and that. If this iterator is shorter than that, thisElem values are used to pad the result. If that is shorter than this iterator, thatElem values are used to pad the result.

    Attributes
    abstract
  116. def zipAll [B, A1 >: A, B1 >: B] (that: Iterator[B], thisElem: A1, thatElem: B1): Iterator[(A1, B1)]

    Creates an iterator formed from this iterator and another iterator by combining corresponding elements in pairs.

    Creates an iterator formed from this iterator and another iterator by combining corresponding elements in pairs. If one of the two iterators is shorter than the other, placeholder elements are used to extend the shorter iterator to the length of the longer.

    that

    iterator that may have a different length as the self iterator.

    thisElem

    element thisElem is used to fill up the resulting iterator if the self iterator is shorter than that

    thatElem

    element thatElem is used to fill up the resulting iterator if that is shorter than the self iterator

    returns

    a new iterator containing pairs consisting of corresponding values of this iterator and that. The length of the returned iterator is the maximum of the lengths of this iterator and that. If this iterator is shorter than that, thisElem values are used to pad the result. If that is shorter than this iterator, thatElem values are used to pad the result.

  117. def zipWithIndex : Iterator[(A, Int)] { ... /* 2 definitions in type refinement */ }

    Creates an iterator that pairs each element produced by this iterator with its index, counting from 0.

  118. def append [B >: A] (that: Iterator[B]): Iterator[B]

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

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

    Annotations
    @deprecated
    Deprecated

    use ++

  119. def counted : CountedIterator[A]

    Returns a counted iterator from this iterator.

    Returns a counted iterator from this iterator.

    Annotations
    @deprecated
    Deprecated

    use zipWithIndex in Iterator

  120. def findIndexOf (p: (A) ⇒ Boolean): Int

    Returns index of the first element satisfying a predicate, or -1.

    Returns index of the first element satisfying a predicate, or -1.

    Annotations
    @deprecated
    Deprecated

    use indexWhere instead

  121. def readInto [B >: A] (xs: Array[B]): Unit

    Annotations
    @deprecated
    Deprecated

    use copyToArray instead

  122. def readInto [B >: A] (xs: Array[B], start: Int): Unit

    Annotations
    @deprecated
    Deprecated

    use copyToArray instead

  123. def readInto [B >: A] (xs: Array[B], start: Int, sz: Int): Unit

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

    Fills the given array xs with the elements of this sequence starting at position start. Like copyToArray, but designed to accomodate IO stream operations.

    Note: the array must be large enough to hold sz elements.

    xs

    the array to fill.

    start

    the starting index.

    sz

    the maximum number of elements to be read.

    Annotations
    @deprecated
    Deprecated

    use copyToArray instead

Inherited from TraversableOnce[A]

Inherited from GenTraversableOnce[A]

Inherited from AnyRef

Inherited from Any