public interface StepperLike<A,CC>
Modifier and Type | Method and Description |
---|---|
StepperLike<A,CC> |
anticipateParallelism()
Warns this `Stepper` that it is likely to be used in a parallel context (used for efficiency only)
|
int |
characteristics()
Characteristics are bit flags that indicate runtime characteristics of this Stepper.
|
long |
count()
Consumes all remaining elements in this
Stepper and counts how many there are. |
long |
count(scala.Function1<A,java.lang.Object> p)
Consumes all remaining elements in this
Stepper and counts how many satisfy condition p . |
boolean |
exists(scala.Function1<A,java.lang.Object> p)
Searches for an element that satisfies condition
p . |
scala.Option<A> |
find(scala.Function1<A,java.lang.Object> p)
Searches for an element that satisifes condition
p , returning it wrapped in Some if one is found, or None otherwise. |
<B> B |
fold(B zero,
scala.Function2<B,A,B> op)
Repeatedly applies
op to propagate an initial value zero through all elements of the collection. |
<B> B |
foldTo(B zero,
scala.Function2<B,A,B> op,
scala.Function1<B,java.lang.Object> p)
Repeatedly applies
op to propagate an initial value zero through the collection until a condition p is met. |
void |
foreach(scala.Function1<A,scala.runtime.BoxedUnit> f)
Applies
f to every remaining element in the collection. |
boolean |
hasStep()
`true` if there are more elements to step through, `false` if not.
|
scala.collection.Iterator<A> |
iterator()
Returns this
Stepper as a Scala Iterator . |
long |
knownSize()
Returns the size of the collection, if known exactly, or `-1` if not.
|
A |
nextStep()
The next element traversed by this Stepper.
|
A |
reduce(scala.Function2<A,A,A> op)
Repeatedly merges elements with
op until only a single element remains. |
java.util.Spliterator<A> |
spliterator()
Returns this
Stepper as a java.util.Spliterator . |
CC |
substep()
Attempt to split this
Stepper in half, with the new (returned) copy taking the first half
of the collection, and this one advancing to cover the second half. |
<Coll> Coll |
to(scala.collection.generic.CanBuildFrom<scala.runtime.Nothing$,A,Coll> cbf)
Returns a Scala collection of the type requested.
|
boolean |
tryStep(scala.Function1<A,scala.runtime.BoxedUnit> f)
If another element exists, apply `f` to it and return `true`; otherwise, return `false`.
|
StepperLike<A,CC> anticipateParallelism()
int characteristics()
- Distinct
means that no duplicates exist
- Immutable
means that the underlying collection is guaranteed not to change during traversal
- NonNull
means that no nulls will be returned during traversal
- Sized
means that the collection knows its exact size
- SubSized
means that sub-Steppers created with substep()
will also know their own size. SubSized
steppers must also be Sized
.
The Java flags CONCURRENT
and SORTED
are not supported; modification of a concurrency-aware underlying collection is not
guaranteed to be any safer than modification of any generic mutable collection, and if the underlying collection is ordered by
virtue of sorting, Stepper
will not keep track of that fact.
long count()
Stepper
and counts how many there are.
This is a terminal operation, though if knownSize
is non-negative, it won't actually
iterate over the elements.long count(scala.Function1<A,java.lang.Object> p)
Stepper
and counts how many satisfy condition p
.
This is a terminal operation.p
- (undocumented)boolean exists(scala.Function1<A,java.lang.Object> p)
p
. If none are found, it returns false
.
This is a terminal operation.p
- (undocumented)scala.Option<A> find(scala.Function1<A,java.lang.Object> p)
p
, returning it wrapped in Some
if one is found, or None
otherwise.
This is a terminal operation.p
- (undocumented)<B> B fold(B zero, scala.Function2<B,A,B> op)
op
to propagate an initial value zero
through all elements of the collection.
Traversal order is left-to-right.
This is a terminal operation.zero
- (undocumented)op
- (undocumented)<B> B foldTo(B zero, scala.Function2<B,A,B> op, scala.Function1<B,java.lang.Object> p)
op
to propagate an initial value zero
through the collection until a condition p
is met.
If p
is never met, the result of the last operation is returned.
This is a terminal operation.zero
- (undocumented)op
- (undocumented)p
- (undocumented)void foreach(scala.Function1<A,scala.runtime.BoxedUnit> f)
f
to every remaining element in the collection.
This is a terminal operation.f
- (undocumented)boolean hasStep()
scala.collection.Iterator<A> iterator()
Stepper
as a Scala Iterator
.
This is a terminal operation.long knownSize()
A nextStep()
nextStep()
throws an exception if no elements exist, so check hasStep
immediately prior
to calling. Note that tryStep
also consumes an element, so the result of hasStep
will
be invalid after tryStep
is called.A reduce(scala.Function2<A,A,A> op)
op
until only a single element remains.
Throws an exception if the Stepper
is empty.
Merging occurs from left to right.
This is a terminal operation.op
- (undocumented)java.util.Spliterator<A> spliterator()
Stepper
as a java.util.Spliterator
.
This is a terminal operation.CC substep()
Stepper
in half, with the new (returned) copy taking the first half
of the collection, and this one advancing to cover the second half. If subdivision is not
possible or not advisable, substep()
will return null
.<Coll> Coll to(scala.collection.generic.CanBuildFrom<scala.runtime.Nothing$,A,Coll> cbf)
boolean tryStep(scala.Function1<A,scala.runtime.BoxedUnit> f)