ListUtil { @Pure public static <T> int getInsertionIndex(List<T> list, Comparator<? super T> comparator, T elt) { return getInsertionIndex(list, comparator, elt, true); } private  ListUtil(); static int remove(List<E> list, Comparator<? super E> comparator, E data); @Inline(value = "add($1, $2, $3, false, false)") static int addIfAbsent(List<E> list, Comparator<? super E> comparator, E data); static int add(List<E> list, Comparator<? super E> comparator, E data,
			boolean allowMultipleOccurencesOfSameValue, boolean allowReplacement); @Pure static boolean contains(List<E> list, Comparator<? super E> comparator, E data); @Pure static int indexOf(List<T> list, Comparator<? super T> comparator, T elt); @Pure static int lastIndexOf(List<T> list, Comparator<? super T> comparator, T elt); @Pure static int getInsertionIndex(List<T> list, Comparator<? super T> comparator, T elt); @Pure static int getInsertionIndex(List<T> list, Comparator<? super T> comparator, T elt, boolean allowMultiple); @Pure static int ceilingIndex(List<T> list, Comparator<? super T> comparator, T elt); @Pure static int floorIndex(List<T> list, Comparator<? super T> comparator, T elt); @Pure static int higherIndex(List<T> list, Comparator<? super T> comparator, T elt); @Pure static int lowerIndex(List<T> list, Comparator<? super T> comparator, T elt); static Iterator<T> reverseIterator(final List<T> list);  }
@Test public void getInsertionIndexComparatorTList() { List<Integer> list = new ArrayList<>(); list.addAll(Arrays.asList(1, 4, 6, 12, 30)); assertEquals(0, ListUtil.getInsertionIndex(list, new NaturalOrderComparator<Integer>(), -2)); assertEquals(2, ListUtil.getInsertionIndex(list, new NaturalOrderComparator<Integer>(), 4)); assertEquals(4, ListUtil.getInsertionIndex(list, new NaturalOrderComparator<Integer>(), 16)); Iterator<Integer> iterator = list.iterator(); assertEquals(Integer.valueOf(1), iterator.next()); assertEquals(Integer.valueOf(4), iterator.next()); assertEquals(Integer.valueOf(6), iterator.next()); assertEquals(Integer.valueOf(12), iterator.next()); assertEquals(Integer.valueOf(30), iterator.next()); assertFalse(iterator.hasNext()); }
@Test public void getInsertionIndexComparatorTListBoolean_true() { List<Integer> list = new ArrayList<>(); list.addAll(Arrays.asList(1, 4, 6, 12, 30)); assertEquals(0, ListUtil.getInsertionIndex(list, new NaturalOrderComparator<Integer>(), -2, true)); assertEquals(2, ListUtil.getInsertionIndex(list, new NaturalOrderComparator<Integer>(), 4, true)); assertEquals(4, ListUtil.getInsertionIndex(list, new NaturalOrderComparator<Integer>(), 16, true)); Iterator<Integer> iterator = list.iterator(); assertEquals(Integer.valueOf(1), iterator.next()); assertEquals(Integer.valueOf(4), iterator.next()); assertEquals(Integer.valueOf(6), iterator.next()); assertEquals(Integer.valueOf(12), iterator.next()); assertEquals(Integer.valueOf(30), iterator.next()); assertFalse(iterator.hasNext()); }
@Test public void getInsertionIndexComparatorTListBoolean_false() { List<Integer> list = new ArrayList<>(); list.addAll(Arrays.asList(1, 4, 6, 12, 30)); assertEquals(0, ListUtil.getInsertionIndex(list, new NaturalOrderComparator<Integer>(), -2, false)); assertEquals(-1, ListUtil.getInsertionIndex(list, new NaturalOrderComparator<Integer>(), 4, false)); assertEquals(4, ListUtil.getInsertionIndex(list, new NaturalOrderComparator<Integer>(), 16, false)); Iterator<Integer> iterator = list.iterator(); assertEquals(Integer.valueOf(1), iterator.next()); assertEquals(Integer.valueOf(4), iterator.next()); assertEquals(Integer.valueOf(6), iterator.next()); assertEquals(Integer.valueOf(12), iterator.next()); assertEquals(Integer.valueOf(30), iterator.next()); assertFalse(iterator.hasNext()); }