trait Iterator[+A] extends IterableOnce[A]

A core Iterator class

Self Type
Iterator[A]
Linear Supertypes
IterableOnce[A], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Iterator
  2. IterableOnce
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
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.

    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.

    Typical uses can be achieved via methods grouped and sliding.

Abstract Value Members

  1. abstract def hasNext: Boolean
  2. abstract def next(): A
    Annotations
    @throws( ... )

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def ++[B >: A](xs: ⇒ IterableOnce[B]): Iterator[B]
    Annotations
    @inline()
  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder

    Appends all elements of this $coll to a string builder using start, end, and separator strings.

    Appends all elements of this $coll 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 $coll are separated by the string sep.

    Example:

    scala> val a = List(1,2,3,4)
    a: List[Int] = List(1, 2, 3, 4)
    
    scala> val b = new StringBuilder()
    b: StringBuilder =
    
    scala> a.addString(b , "List(" , ", " , ")")
    res5: StringBuilder = List(1, 2, 3, 4)
    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.

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. 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).

    Note

    Reuse: $consumesAndProducesIterator

  9. def concat[B >: A](xs: ⇒ IterableOnce[B]): Iterator[B]
  10. 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. $mayNotTerminateInf

    elem

    the element to test.

    returns

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

    Note

    Reuse: After calling this method, one should discard the iterator it was called on. Using it is undefined and subject to change.

  11. def count(p: (A) ⇒ Boolean): Int

    Counts the number of elements in the $coll which satisfy a predicate.

    Counts the number of elements in the $coll which satisfy a predicate.

    p

    the predicate used to test elements.

    returns

    the number of elements satisfying the predicate p.

  12. def distinct: Iterator[A]

    Builds a new iterator from this one without any duplicated elements on it.

    Builds a new iterator from this one without any duplicated elements on it.

    returns

    iterator with distinct elements

    Note

    Reuse: After calling this method, one should discard the iterator it was called on. Using it is undefined and subject to change.

  13. def distinctBy[B](f: (A) ⇒ B): Iterator[A]

    Builds a new iterator from this one without any duplicated elements as determined by == after applying the transforming function f.

    Builds a new iterator from this one without any duplicated elements as determined by == after applying the transforming function f.

    B

    the type of the elements after being transformed by f

    f

    The transforming function whose result is used to determine the uniqueness of each element

    returns

    iterator with distinct elements

    Note

    Reuse: After calling this method, one should discard the iterator it was called on. Using it is undefined and subject to change.

  14. def drop(n: Int): Iterator[A]
  15. 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

    Note

    Reuse: $consumesAndProducesIterator

  16. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  18. 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. $mayNotTerminateInf

    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.

    Note

    Reuse: After calling this method, one should discard the iterator it was called on. Using it is undefined and subject to change.

  19. def filter(p: (A) ⇒ Boolean): Iterator[A]

    Selects all elements of this iterator which satisfy a predicate.

    Selects all elements of this iterator which satisfy a predicate.

    p

    the predicate used to test elements.

    returns

    a new iterator consisting of all elements of this $coll that satisfy the given predicate p. The order of the elements is preserved.

  20. 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.

    Note

    Reuse: $consumesAndProducesIterator

  21. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  22. 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. $mayNotTerminateInf

    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.

    Note

    Reuse: After calling this method, one should discard the iterator it was called on. Using it is undefined and subject to change.

  23. def flatMap[B](f: (A) ⇒ IterableOnce[B]): Iterator[B]
  24. def foldLeft[B](z: B)(op: (B, A) ⇒ B): B
  25. def foldRight[B](z: B)(op: (A, B) ⇒ B): B
  26. 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. $mayNotTerminateInf

    p

    the predicate used to test elements.

    returns

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

    Note

    Reuse: After calling this method, one should discard the iterator it was called on. Using it is undefined and subject to change.

  27. def foreach[U](f: (A) ⇒ U): Unit
  28. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  29. 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
    Note

    Reuse: $consumesAndProducesIterator

  30. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  31. def indexOf[B >: A](elem: B, from: Int): Int

    Returns the index of the first occurrence of the specified object in this iterable object after or at some start index.

    Returns the index of the first occurrence of the specified object in this iterable object after or at some start index. $mayNotTerminateInf

    elem

    element to search for.

    from

    the start index

    returns

    the index >= from 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.

    Note

    Reuse: After calling this method, one should discard the iterator it was called on. Using it is undefined and subject to change.

  32. 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. $mayNotTerminateInf

    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.

    Note

    Reuse: After calling this method, one should discard the iterator it was called on. Using it is undefined and subject to change.

  33. def indexWhere(p: (A) ⇒ Boolean, from: Int = 0): Int
  34. def isEmpty: Boolean

    Tests whether this iterator is empty.

    Tests whether this iterator is empty.

    returns

    true if hasNext is false, false otherwise.

    Note

    Reuse: $preservesIterator

  35. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  36. def iterator(): Iterator[A]

    Iterator can be used only once

    Iterator can be used only once

    Definition Classes
    IteratorIterableOnce
  37. final def knownSize: Int
    Definition Classes
    IteratorIterableOnce
  38. def length: Int
  39. def map[B](f: (A) ⇒ B): Iterator[B]
  40. def mkString: String
  41. def mkString(sep: String): String
  42. def mkString(start: String, sep: String, end: String): String
  43. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  44. def nextOption(): Option[A]

    Wraps the value of next() in an option.

    Wraps the value of next() in an option.

    returns

    Some(next) if a next element exists, None otherwise.

  45. final def notify(): Unit
    Definition Classes
    AnyRef
  46. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  47. 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. Patching at negative indices is the same as patching starting at 0. Patching at indices at or larger than the length of the original iterator appends the patch to the end. If more values are replaced than actually exist, the excess is ignored.

    from

    The start index from which to patch

    patchElems

    The iterator of patch values

    replaced

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

    Note

    Reuse: $consumesTwoAndProducesOneIterator

  48. def sameElements[B >: A](that: IterableOnce[B]): Boolean
  49. def scanLeft[B](z: B)(op: (B, A) ⇒ B): Iterator[B]

    Produces a collection containing cumulative results of applying the operator going left to right.

    Produces a collection containing cumulative results of applying the operator going left to right.

    $willNotTerminateInf $orderDependent

    B

    the type of the elements in the resulting collection

    z

    the initial value

    op

    the binary operator applied to the intermediate result and the element

    returns

    iterator with intermediate results

    Note

    Reuse: $consumesAndProducesIterator

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

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

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

    The default GroupedIterator can be configured to either pad a partial result to size size or suppress the partial result entirely.

    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
    returns

    An iterator producing Seq[B]s of size size, except the last element (which may be the only element) will be truncated if there are fewer than size elements remaining to be grouped. This behavior can be configured.

    Note

    Reuse: $consumesAndProducesIterator

  52. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  53. def take(n: Int): Iterator[A]
  54. 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.

    Note

    Reuse: $consumesAndProducesIterator

  55. def to[C](factory: Factory[A, C]): C

    Converts this Iterator into another collection.

    Converts this Iterator into another collection.

    C

    The collection type to build.

    factory

    Collection factory to use. The factory may or may not eagerly consume this iterator.

    returns

    a new collection containing all elements of this Iterator.

  56. def toString(): String
    Definition Classes
    AnyRef → Any
  57. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  58. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  59. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  60. 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.

    Note

    Reuse: $consumesAndProducesIterator

  61. def zip[B](that: IterableOnce[B]): Iterator[(A, B)]
  62. def zipWithIndex: Iterator[(A, Int)]

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

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

    returns

    a new iterator containing pairs consisting of corresponding elements of this iterator and their indices.

    Note

    Reuse: $consumesAndProducesIterator

Inherited from IterableOnce[A]

Inherited from AnyRef

Inherited from Any

Ungrouped