Packages

trait Stepper[+A] extends AnyRef

Steppers exist to enable creating Java streams over Scala collections, see scala.jdk.StreamConverters. Besides that use case, they allow iterating over collections holding unboxed primitives (e.g., Array[Int]) without boxing the elements.

Steppers have an iterator-like interface with methods hasStep and nextStep(). The difference to iterators - and the reason Stepper is not a subtype of Iterator - is that there are hand-specialized variants of Stepper for Int, Long and Double (IntStepper, etc.). These enable iterating over collections holding unboxed primitives (e.g., Arrays, scala.jdk.Accumulators) without boxing the elements.

The selection of primitive types (Int, Long and Double) matches the hand-specialized variants of Java Streams (java.util.stream.Stream, java.util.stream.IntStream, etc.) and the corresponding Java Spliterators (java.util.Spliterator, java.util.Spliterator.OfInt, etc.).

Steppers can be converted to Scala Iterators, Java Iterators and Java Spliterators. Primitive Steppers are converted to the corresponding primitive Java Iterators and Spliterators.

A

the element type of the Stepper

Source
Stepper.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Stepper
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def characteristics: Int

    Returns a set of characteristics of this Stepper and its elements.

    Returns a set of characteristics of this Stepper and its elements. See method characteristics in java.util.Spliterator.

  2. abstract def estimateSize: Long

    Returns an estimate of the number of elements of this Stepper, or Long.MaxValue.

    Returns an estimate of the number of elements of this Stepper, or Long.MaxValue. See method estimateSize in java.util.Spliterator.

  3. abstract def hasStep: Boolean

    Check if there's an element available.

  4. abstract def javaIterator[B >: A]: java.util.Iterator[_]

    Returns a Java java.util.Iterator corresponding to this Stepper.

    Returns a Java java.util.Iterator corresponding to this Stepper.

    Note that the return type is Iterator[_] instead of Iterator[A] to allow returning a java.util.PrimitiveIterator.OfInt (which is a Iterator[Integer]) in the subclass IntStepper (which is a Stepper[Int]).

  5. abstract def nextStep(): A

    Return the next element and advance the stepper

  6. abstract def spliterator[B >: A]: Spliterator[_]

    Returns a java.util.Spliterator corresponding to this Stepper.

    Returns a java.util.Spliterator corresponding to this Stepper.

    Note that the return type is Spliterator[_] instead of Spliterator[A] to allow returning a java.util.Spliterator.OfInt (which is a Spliterator[Integer]) in the subclass IntStepper (which is a Stepper[Int]).

  7. abstract def trySplit(): Stepper[A]

    Split this stepper, if applicable.

    Split this stepper, if applicable. The elements of the current Stepper are split up between the resulting Stepper and the current stepper.

    May return null, in which case the current Stepper yields the same elements as before.

    See method trySplit in java.util.Spliterator.

Concrete Value Members

  1. def iterator: Iterator[A]

    Returns an Iterator corresponding to this Stepper.

    Returns an Iterator corresponding to this Stepper. Note that Iterators corresponding to primitive Steppers box the elements.