/** * Returns a sequential ordered {@code IntStreamEx} 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 IntStreamEx} for the range of {@code int} * elements * @throws IllegalArgumentException if step is zero * @see IntStreamEx#range(int, int) * @since 0.4.0 */ public static IntStreamEx range(int startInclusive, int endExclusive, int step) { int endInclusive = endExclusive - Integer.signum(step); if (endInclusive > endExclusive && step > 0 || endInclusive < endExclusive && step < 0) return empty(); return rangeClosed(startInclusive, endInclusive, step); }