Java Code Examples for java.util.stream.LongStream#rangeClosed()

The following examples show how to use java.util.stream.LongStream#rangeClosed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoreStreams.java    From more-lambdas-java with Artistic License 2.0 5 votes vote down vote up
public static LongStream longRangeClosed(long from, long to) {
    if (from <= to) {
        return LongStream.rangeClosed(from, to);
    } else {
        return LongStream.rangeClosed(to, from).map(i -> to - i + from);
    }
}
 
Example 2
Source File: MoreIterables.java    From more-lambdas-java with Artistic License 2.0 5 votes vote down vote up
public static Iterable<List<Long>> batchClosedRange(long from, long to, int batch) {
    checkArgument(batch > 0);
    if (from == to) {
        return singleton(singletonList(from));
    }
    LongStream longStream;
    if (from > to) {
        longStream = LongStream.rangeClosed(to, from).map(i -> from + to - i);
    } else {
        longStream = LongStream.rangeClosed(from, to);
    }
    return partition(longStream.boxed()::iterator, batch);
}
 
Example 3
Source File: Utils.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * Gets a stream of values from a range.
 */
public static LongStream rangeValues(Protos.Value.Range range) {
	checkNotNull(range);
	return LongStream.rangeClosed(range.getBegin(), range.getEnd());
}
 
Example 4
Source File: Utils.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Gets a stream of values from a range.
 */
public static LongStream rangeValues(Protos.Value.Range range) {
	checkNotNull(range);
	return LongStream.rangeClosed(range.getBegin(), range.getEnd());
}
 
Example 5
Source File: RangeUtils.java    From kafka-workers with Apache License 2.0 4 votes vote down vote up
public static LongStream elementsStream(ClosedRange closedRange) {
    return LongStream.rangeClosed(closedRange.lowerEndpoint(), closedRange.upperEndpoint());
}
 
Example 6
Source File: Utils.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Gets a stream of values from a range.
 */
public static LongStream rangeValues(Protos.Value.Range range) {
	checkNotNull(range);
	return LongStream.rangeClosed(range.getBegin(), range.getEnd());
}