public final class RangeExtensions extends Object
IntegerRange
. To use these methods in Xtend, import this class via import static extension de.fhg.fokus.xtensions.range.RangeExtensions.*
Modifier and Type | Method and Description |
---|---|
static IntIterable |
asIntIterable(IntegerRange r)
Provides an
IntIterable view on the given IntegerRange r . |
static void |
forEachInt(IntegerRange r,
IntConsumer consumer)
This method iterates over all integers in range
r and applies the given consumer for every element.This method is more efficient than the generic iteration extension method IterableExtensions#forEach
because it uses IntConsumer as the receiver of elements in the range, which prevents boxing of the integer values. |
static void |
forEachInt(IntegerRange r,
IntIntConsumer consumer)
This method iterates over all integers in range
r and applies the given consumer for every element, additionally with the index in the range (starting with index 0). |
static PrimitiveIterator.OfInt |
intIterator(IntegerRange r) |
static IntStream |
parallelStream(IntegerRange r)
|
static IntStream |
stream(IntegerRange r)
|
public static void forEachInt(IntegerRange r, IntConsumer consumer)
r
and applies the given consumer
for every element.IterableExtensions#forEach
because it uses IntConsumer
as the receiver of elements in the range, which prevents boxing of the integer values.r
- the range to iterate over. Must not be null
consumer
- the function that is called for each element in the range r
.NullPointerException
- if r
or consumer
is null
public static void forEachInt(IntegerRange r, IntIntConsumer consumer)
r
and applies the given consumer
for every element, additionally with the index in the range (starting with index 0).
The first element passed to the consumer is an element from the range, the second one the index.IterableExtensions#forEach
because it uses IntIntConsumer
as the receiver of elements in the range, which prevents boxing of the integer values.r
- the range to iterate over. Must not be null
consumer
- the function that is called for each element in the range r
and the index in the range (starting with 0).NullPointerException
- if r
or consumer
is null
public static IntStream stream(IntegerRange r)
r
- the range for which the returning stream will be created.r
.public static IntStream parallelStream(IntegerRange r)
r
- the range for which a parallel stream will be createdr
.public static PrimitiveIterator.OfInt intIterator(IntegerRange r)
public static IntIterable asIntIterable(IntegerRange r)
IntIterable
view on the given IntegerRange r
.r
- range to create the view forIntIterable
view on the given IntegerRange r
.Copyright © 2019. All rights reserved.