/** * Returns a stream consisting of the elements of this stream that strictly * less than the specified value. * * <p> * This is an intermediate operation. * * @param value a value to compare to * @return the new stream * @since 0.2.3 */ public IntStreamEx less(int value) { return filter(val -> val < value); }
/** * Returns a stream consisting of the elements of this stream that strictly * greater than the specified value. * * <p> * This is an intermediate operation. * * @param value a value to compare to * @return the new stream * @since 0.2.3 */ public IntStreamEx greater(int value) { return filter(val -> val > value); }
/** * Returns a stream consisting of the elements of this stream that greater * than or equal to the specified value. * * <p> * This is an intermediate operation. * * @param value a value to compare to * @return the new stream * @since 0.2.3 */ public IntStreamEx atLeast(int value) { return filter(val -> val >= value); }
/** * Returns a stream consisting of the elements of this stream that less than * or equal to the specified value. * * <p> * This is an intermediate operation. * * @param value a value to compare to * @return the new stream * @since 0.2.3 */ public IntStreamEx atMost(int value) { return filter(val -> val <= value); }
/** * Returns a stream consisting of the elements of this stream that don't * equal to the given value. * * <p> * This is an intermediate operation. * * @param value the value to remove from the stream. * @return the new stream * @since 0.2.2 * @see #without(int...) * @see #remove(IntPredicate) */ public IntStreamEx without(int value) { return filter(val -> val != value); }
/** * Returns a stream consisting of the elements of this stream that don't * match the given predicate. * * <p> * This is an intermediate operation. * * @param predicate a non-interfering, stateless predicate to apply to each * element to determine if it should be excluded * @return the new stream */ public IntStreamEx remove(IntPredicate predicate) { return filter(predicate.negate()); }
/** * Returns an {@link OptionalInt} describing the first element of this * stream, which matches given predicate, or an empty {@code OptionalInt} if * there's no matching element. * * <p> * This is a short-circuiting terminal operation. * * @param predicate a * <a href="package-summary.html#NonInterference">non-interfering * </a>, <a href="package-summary.html#Statelessness">stateless</a> * predicate which returned value should match * @return an {@code OptionalInt} describing the first matching element of * this stream, or an empty {@code OptionalInt} if there's no * matching element * @see #findFirst() */ public OptionalInt findFirst(IntPredicate predicate) { return filter(predicate).findFirst(); }
/** * Returns an {@link OptionalInt} describing some element of the stream, * which matches given predicate, or an empty {@code OptionalInt} if there's * no matching element. * * <p> * This is a short-circuiting terminal operation. * * <p> * The behavior of this operation is explicitly nondeterministic; it is free * to select any element in the stream. This is to allow for maximal * performance in parallel operations; the cost is that multiple invocations * on the same source may not return the same result. (If a stable result is * desired, use {@link #findFirst(IntPredicate)} instead.) * * @param predicate a * <a href="package-summary.html#NonInterference">non-interfering * </a>, <a href="package-summary.html#Statelessness">stateless</a> * predicate which returned value should match * @return an {@code OptionalInt} describing some matching element of this * stream, or an empty {@code OptionalInt} if there's no matching * element * @see #findAny() * @see #findFirst(IntPredicate) */ public OptionalInt findAny(IntPredicate predicate) { return filter(predicate).findAny(); }
if (values.length == 1) return without(values[0]); return filter(x -> { for (int val : values) { if (x == val)