/** * Returns a sequential ordered {@code LongStreamEx} from * {@code startInclusive} (inclusive) to {@code endExclusive} (exclusive) by * the specified incremental step. The negative step values are also * supported. In this case the {@code startInclusive} should be greater than * {@code endExclusive}. * * @param startInclusive the (inclusive) initial value * @param endExclusive the exclusive upper bound * @param step the non-zero value which designates the difference between * the consecutive values of the resulting stream. * @return a sequential {@code LongStreamEx} for the range of {@code long} * elements * @throws IllegalArgumentException if step is zero * @see LongStreamEx#range(long, long) * @since 0.4.0 */ public static LongStreamEx range(long startInclusive, long endExclusive, long step) { long endInclusive = endExclusive - Long.signum(step); if (endInclusive > endExclusive && step > 0 || endInclusive < endExclusive && step < 0) return empty(); return rangeClosed(startInclusive, endInclusive, step); }