add union(IntList,IntList) and addAll(IntList)

IntPredicate gets the current value and the index.
This was handy while removing duplicate values.
This commit is contained in:
2017-12-12 18:45:11 +01:00
parent 3dd1955749
commit 76e5dc403c
3 changed files with 296 additions and 29 deletions

View File

@@ -11,11 +11,13 @@ public interface IntPredicate {
/**
* Evaluates the predicate.
*
* @param i
* the input argument
* @param value
* the value
* @param index
* the index in the list
* @return {@code true} iff the input argument matches the predicate
*/
boolean test(int i);
boolean test(int value, int index);
/**
* Returns a predicate that represents the logical AND of {@code this} and
@@ -28,7 +30,7 @@ public interface IntPredicate {
* if {@code other} is null
*/
default IntPredicate and(final IntPredicate other) {
return (t) -> test(t) && other.test(t);
return (value, index) -> test(value, index) && other.test(value, index);
}
/**
@@ -42,7 +44,7 @@ public interface IntPredicate {
* if {@code other} is null
*/
default IntPredicate or(final IntPredicate other) {
return (t) -> test(t) || other.test(t);
return (value, index) -> test(value, index) || other.test(value, index);
}
/**
@@ -51,6 +53,6 @@ public interface IntPredicate {
* @return the negation of {@code this}
*/
default IntPredicate negate() {
return (t) -> !test(t);
return (value, index) -> !test(value, index);
}
}