add method removeIf
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package org.lucares.collections;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* A {@link Predicate} for primitive integers.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IntPredicate {
|
||||
|
||||
/**
|
||||
* Evaluates the predicate.
|
||||
*
|
||||
* @param i
|
||||
* the input argument
|
||||
* @return {@code true} iff the input argument matches the predicate
|
||||
*/
|
||||
boolean test(int i);
|
||||
|
||||
/**
|
||||
* Returns a predicate that represents the logical AND of {@code this} and
|
||||
* another predicate. The and operation is short-circuiting.
|
||||
*
|
||||
* @param other
|
||||
* the other predicate
|
||||
* @return the result of combining both predicates with a logical AND operation
|
||||
* @throws NullPointerException
|
||||
* if {@code other} is null
|
||||
*/
|
||||
default IntPredicate and(final IntPredicate other) {
|
||||
return (t) -> test(t) && other.test(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that represents the logical OR of {@code this} and
|
||||
* another predicate. The and operation is short-circuiting.
|
||||
*
|
||||
* @param other
|
||||
* the other predicate
|
||||
* @return the result of combining both predicates with a logical OR operation
|
||||
* @throws NullPointerException
|
||||
* if {@code other} is null
|
||||
*/
|
||||
default IntPredicate or(final IntPredicate other) {
|
||||
return (t) -> test(t) || other.test(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a predicate that negates the result of this predicate.
|
||||
*
|
||||
* @return the negation of {@code this}
|
||||
*/
|
||||
default IntPredicate negate() {
|
||||
return (t) -> !test(t);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user