List of usage examples for java.util.function BiPredicate test
boolean test(T t, U u);
From source file:Main.java
public static void main(String[] args) { BiPredicate<Integer, Integer> bi = (x, y) -> x > y; System.out.println(bi.test(2, 3)); }
From source file:Main.java
public static void main(String[] args) { BiPredicate<Integer, Integer> bi = (x, y) -> x > y; System.out.println(bi.test(2, 3)); System.out.println(bi.negate().test(2, 3)); }
From source file:Main.java
public static void main(String[] args) { BiPredicate<Integer, Integer> bi = (x, y) -> x > y; BiPredicate<Integer, Integer> eq = (x, y) -> x - 2 > y; System.out.println(bi.test(2, 3)); System.out.println(bi.and(eq).test(2, 3)); System.out.println(bi.and(eq).test(8, 3)); }
From source file:Main.java
public static void main(String[] args) { BiPredicate<Integer, Integer> bi = (x, y) -> x > y; BiPredicate<Integer, Integer> eq = (x, y) -> x - 2 > y; System.out.println(bi.test(2, 3)); System.out.println(bi.or(eq).test(2, 3)); System.out.println(bi.or(eq).test(8, 3)); }
From source file:Main.java
public static boolean compare(BiPredicate<Integer, Integer> bi, Integer i1, Integer i2) { return bi.test(i1, i2); }
From source file:Main.java
public static <E> boolean contains(Collection<E> c, E item, BiPredicate<? super E, ? super E> equalTester) { Iterator<E> iter = c.iterator(); while (iter.hasNext()) { if (equalTester.test(iter.next(), item)) { return true; }//from w ww . ja v a 2 s . c o m } return false; }
From source file:Main.java
public static <E> int indexOf(List<E> c, E item, BiPredicate<? super E, ? super E> equalTester) { ListIterator<E> iter = c.listIterator(); while (iter.hasNext()) { int index = iter.nextIndex(); if (equalTester.test(iter.next(), item)) { return index; }/*from www . ja v a2 s .c om*/ } return -1; }
From source file:com.uber.hoodie.common.table.HoodieTimeline.java
static boolean compareTimestamps(String commit1, String commit2, BiPredicate<String, String> predicateToApply) { return predicateToApply.test(commit1, commit2); }
From source file:Main.java
public static <E> E setInSortedList(List<E> list, int index, E item, Comparator<? super E> comparator, BiPredicate<? super E, ? super E> distincter) { if (distincter != null) { ListIterator<E> iter = list.listIterator(); while (iter.hasNext()) { int currIndex = iter.nextIndex(); E currItem = iter.next();//w w w. j a v a2 s .c o m if (index != currIndex && distincter.test(currItem, item)) { return null; } } } E previousItem = list.set(index, item); list.sort(comparator); return previousItem; }
From source file:Main.java
public static <E> boolean addToSortedList(List<E> list, E item, Comparator<? super E> comparator, BiPredicate<? super E, ? super E> distincter) { int addIndex = list.size(); boolean foundAddIndex = false; ListIterator<E> iter = list.listIterator(); while (iter.hasNext()) { int currIndex = iter.nextIndex(); E currItem = iter.next();/*w w w . j a v a 2s .com*/ if (distincter != null && distincter.test(currItem, item)) { return false; } if (!foundAddIndex) { int comparison = comparator.compare(currItem, item); if (comparison > 0) { addIndex = currIndex; // if we don't have to check the remaining items for distinct we can break the loop now if (distincter == null) { break; } foundAddIndex = true; } else if (comparison == 0) { addIndex = currIndex + 1; // if we don't have to check the remaining items for distinct we can break the loop now if (distincter == null) { break; } foundAddIndex = true; } } } list.add(addIndex, item); return true; }