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

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

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