goja-core/src/main/java/goja/core/kits/lang/BinarySearch.java
public static <T> BinarySearch<T> forList(final List<T> list, final Comparator<T> comparator) {
        return new BinarySearch<T>() {
            @Override
            @SuppressWarnings({"unchecked"})
            protected int compare(int index, T element) {
                return comparator.compare(list.get(index), element);
            }

            @Override
            protected int getLastIndex() {
                return list.size() - 1;
            }
        };
    }
public static <T> BinarySearch<T> forList(final List<T> list, final Comparator<T> comparator) {
        return new BinarySearch<T>() {
            @Override
            @SuppressWarnings({"unchecked"})
            protected int compare(int index, T element) {
                return comparator.compare(list.get(index), element);
            }

            @Override
            protected int getLastIndex() {
                return list.size() - 1;
            }
        };
    }
public static < T > BinarySearch < T > forList ( final List < T > list , final Comparator < T > comparator ) { return new BinarySearch < T > ( ) { @ Override @ SuppressWarnings ( { "unchecked" } ) protected int compare ( int index , T element ) { return comparator . compare ( list . get ( index ) , element ) ; } @ Override protected int getLastIndex ( ) { return list . size ( ) - 1 ; } } ; }
Creates binary search wrapper over a list with given comparator.
Creates binary search wrapper over a list with given comparator .