public interface DoubleIterable extends Iterable<Double>
Iterable<Double>
providing a PrimitiveIterator.OfDouble
which allows iteration over a (possibly infinite) amount of unboxed primitive values.DoubleStream
would
be appropriate, but the user has to be able to create the stream multiple
times. It can also be used as an immutable view on an double[]
array.Modifier and Type | Method and Description |
---|---|
default void |
forEachDouble(DoubleConsumer consumer)
Iterates over all elements of the iterable and calls
consumer for
each element. |
static DoubleIterable |
generate(Functions.Function0<? extends DoubleSupplier> s)
Creates a new LongIterable that will produce an infinite
PrimitiveIterator.OfDouble or DoubleStream based on the DoubleSupplier provided by supplier s . |
static DoubleIterable |
iterate(double seed,
DoublePredicate hasNext,
DoubleUnaryOperator next)
Creates
DoubleIterable an which works similar to a traditional for-loop. |
static DoubleIterable |
iterate(double seed,
DoubleUnaryOperator op)
Creates
DoubleIterable an infinite providing an infinite source of
numbers, starting with the given seed value and in every
subsequent step the result of the given operator applied on the
last step's value. |
PrimitiveIterator.OfDouble |
iterator()
Returns a primitive iterator over elements of type
double . |
default DoubleStream |
stream()
Returns an
DoubleStream based on the elements in the iterable. |
forEach, spliterator
PrimitiveIterator.OfDouble iterator()
double
. This
method specializes the super-interface method.default void forEachDouble(DoubleConsumer consumer)
consumer
for
each element. The default implementation uses iterator()
to get
the elements of the iterable. Implementations are encouraged to overwrite
this method with a more efficient implementation.consumer
throws an exception or terminates the runtime.consumer
- the action to be called for each element in the iterable.default DoubleStream stream()
DoubleStream
based on the elements in the iterable. PrimitiveIteratorExtensions.streamRemaining(PrimitiveIterator.OfDouble)
with the iterator fromiterator()
to construct the resulting stream. It is highly
recommended for the implementations of this interface to provide an own
implementation of this method.static DoubleIterable generate(Functions.Function0<? extends DoubleSupplier> s)
PrimitiveIterator.OfDouble
or DoubleStream
based on the DoubleSupplier
provided by supplier s
.s
- supplier, that provides an DoubleSupplier
for each
iterator or stream created.s
.static DoubleIterable iterate(double seed, DoubleUnaryOperator op)
DoubleIterable
an infinite providing an infinite source of
numbers, starting with the given seed
value and in every
subsequent step the result of the given operator
applied on the
last step's value. So in the second step this would beop.applyAsDouble(seed)
and so on.seed
- first value to be provided and used as seed fed to op
in second step.op
- this operator must be side-effect free.DoubleIterable
providing infinite source of numbers
based on seed
and op
.static DoubleIterable iterate(double seed, DoublePredicate hasNext, DoubleUnaryOperator next)
DoubleIterable
an which works similar to a traditional for-loop.
The first value provided by an iterator provided by the created iterable will be seed
value.
The iterator's OfDouble#next()
method will return the
boolean value provided by DoublePredicate
on the potentially next value.
This also means that if DoublePredicate
does not hold for the first value
the iterator will not provide any value. The next value provided after the initial
one is next
applied to the initial value. All following values provided by
the iterator will be computed from the last value by applying next
.seed
- initial value to be provided by iteratorshasNext
- method to check if iterator should provide a next valuenext
- value mapping previous value provided by iterator to next value providedseed
, hasNext
, and next
.Copyright © 2019. All rights reserved.