public interface PrimitiveIntIterable
extends java.lang.Iterable<java.lang.Integer>
for creating one on the fly
Modifier and Type | Field and Description |
---|---|
static PrimitiveIntIterable |
EMPTY
Empty iterable of primitive int values.
|
static java.util.PrimitiveIterator.OfInt |
EMPTY_INT_ITERATOR
Empty iterator of primitive int values.
|
Modifier and Type | Method and Description |
---|---|
default java.util.OptionalDouble |
average()
Calculate the average of all elements in this iterable.
|
default boolean |
containsInt(int value)
Does this integer iterable contain the given value?
|
default void |
forEachInt(java.util.function.IntConsumer action)
Invoke the given action with each int value in this iterable.
|
default <E extends java.lang.Exception> |
forEachIntFragile(FragileIntConsumer<E> action)
Invoke the given fragile action with each value in this iterable.
|
java.util.PrimitiveIterator.OfInt |
intIterator()
Get a primitive int iterator.
|
default java.util.Iterator<java.lang.Integer> |
iterator() |
default long |
longSum()
Calculate the sum of the elements of this iterable as a long value.
|
default long |
longSumX()
Calculate the sum of the elements of this iterable as a long value.
|
default java.util.Spliterator.OfInt |
spliterator() |
default java.util.stream.IntStream |
stream()
Get a stream of primitive integer values from this iterable.
|
default int |
sum()
Calculate the sum of the elements of this iterable as an integer value.
|
default int |
sumX()
Calculate the sum of the elements of this iterable as an integer value.
|
static final java.util.PrimitiveIterator.OfInt EMPTY_INT_ITERATOR
static final PrimitiveIntIterable EMPTY
@NotNull java.util.PrimitiveIterator.OfInt intIterator()
@NotNull default java.util.Iterator<java.lang.Integer> iterator()
iterator
in interface java.lang.Iterable<java.lang.Integer>
default void forEachInt(@NotNull java.util.function.IntConsumer action)
action
- action to be called for each int value in sequence.default <E extends java.lang.Exception> void forEachIntFragile(@NotNull FragileIntConsumer<E> action) throws E extends java.lang.Exception
E
- checked exception thrown by actionaction
- action to be called for each value in sequenceE
- if action
throws itE extends java.lang.Exception
default boolean containsInt(int value)
value
- value to check fortrue
if the value is contained in this iterable, false
if notdefault int sum()
Please note that this might silently overflow.
See sumX()
if you want to avoid this
with the price of running much slower, or longSum()
if you want to make an overflow unlikely.
default int sumX()
This will throw an exception if summing up overflows.
java.lang.ArithmeticException
- if summing up overflows the range of int
default long longSum()
default long longSumX()
long
.java.lang.ArithmeticException
- if summing up overflows the range of long
@NotNull default java.util.OptionalDouble average()
Double.NaN
if this iterable is emptsdefault java.util.Spliterator.OfInt spliterator()
spliterator
in interface java.lang.Iterable<java.lang.Integer>
@NotNull default java.util.stream.IntStream stream()
int
stream