java.lang.Object
org.monte.media.util.stream.RangeStream
RangeStream processes a range of integer sequentially or in parallel
sub-ranges.
- Author:
- Werner Randelshofer
-
Method Summary
Modifier and TypeMethodDescriptionvoidforEach(IntConsumer consumer) Invokes the consumer to process an integer from the range until the entire reange is consumed.voidforEach(BiIntConsumer consumer) Invokes the consumer to process sub-ranges until the entire range has been processed.parallel()Converts this stream to a parallel stream which will be recursively split up into ranges down to a threshold of 128.parallel(int threshold) Converts this stream to a parallel stream which will be recursively split up into ranges down to the specified treshold.static RangeStreamrange(int startInclusive, int endExclusive) Returns a range stream which will execute the the integers from startInclusive to endExclusive.serial()Converts this stream back to a serial stream.
-
Method Details
-
parallel
Converts this stream to a parallel stream which will be recursively split up into ranges down to a threshold of 128.- Returns:
- this stream
-
parallel
Converts this stream to a parallel stream which will be recursively split up into ranges down to the specified treshold.- Parameters:
threshold- for recursive splitting, a value smaller or equal 0 convert this stream back into a serial stream- Returns:
- this stream
-
serial
Converts this stream back to a serial stream.- Returns:
- this stream
-
forEach
Invokes the consumer to process an integer from the range until the entire reange is consumed.If this stream is parallel, the consumer is invoked in parallel.
If this stream is sequential, the consumer is invoked sequentially.
- Parameters:
consumer-
-
forEach
Invokes the consumer to process sub-ranges until the entire range has been processed.If this stream is parallel, the range is split up into sub-ranges and the consumer is invoked for each sub-range in parallel.
If this stream is sequential, the consumer is invoked with the entire range.
- Parameters:
consumer-
-
range
Returns a range stream which will execute the the integers from startInclusive to endExclusive.- Parameters:
startInclusive-endExclusive-- Returns:
- RangeStream
-