public class BinarySearch extends Object
Modifier  Constructor  Description 

protected 
BinarySearch() 
Modifier and Type  Method  Description 

static <T,K> int 
lowerBound(T[] a,
K key,
int imin,
int imax,
Function1<T,K> keySelector,
Comparator<K> comparator) 
Taken from http://en.wikipedia.org/wiki/Binary_search_algorithm
#Deferred_detection_of_equality

static <T,K> int 
lowerBound(T[] a,
K key,
Function1<T,K> keySelector,
Comparator<K> comparator) 
Performs binary search of the lower bound in the given array.

static <T> int 
lowerBound(T[] a,
T key,
int imin,
int imax,
Comparator<T> comparator) 
Performs binary search of the lower bound in the given section of array.

static <T> int 
lowerBound(T[] a,
T key,
Comparator<T> comparator) 
Performs binary search of the lower bound in the given array.

static <T,K> int 
upperBound(T[] a,
K key,
int imin,
int imax,
Function1<T,K> keySelector,
Comparator<K> comparator) 
Taken from http://en.wikipedia.org/wiki/Binary_search_algorithm
#Deferred_detection_of_equality
Adapted to find upper bound.

static <T,K> int 
upperBound(T[] a,
K key,
Function1<T,K> keySelector,
Comparator<K> comparator) 
Performs binary search of the upper bound in the given array.

static <T> int 
upperBound(T[] a,
T key,
int imin,
int imax,
Comparator<T> comparator) 
Performs binary search of the upper bound in the given array.

static <T> int 
upperBound(T[] a,
T key,
Comparator<T> comparator) 
Performs binary search of the upper bound in the given array.

public static <T> int lowerBound(T[] a, T key, Comparator<T> comparator)
T
 the type of elements in arraya
 array that holds the valueskey
 element to look forcomparator
 comparator that compares keysa.length
when all
elements are less than the given key.public static <T> int upperBound(T[] a, T key, Comparator<T> comparator)
T
 the type of elements in arraya
 array that holds the valueskey
 element to look forcomparator
 comparator that compares keysa.length
when
all elements exceed the given key.public static <T,K> int lowerBound(T[] a, K key, Function1<T,K> keySelector, Comparator<K> comparator)
T
 the type of elements in arrayK
 the type of lookup keya
 array that holds the valueskey
 element to look forkeySelector
 function that transforms array contents to the type
of the keycomparator
 comparator that compares keysa.length
when all
elements are less than the given key.public static <T,K> int upperBound(T[] a, K key, Function1<T,K> keySelector, Comparator<K> comparator)
T
 the type of elements in arrayK
 the type of lookup keya
 array that holds the valueskey
 element to look forkeySelector
 function that transforms array contents to the type
of the keycomparator
 comparator that compares keysa.length
when
all elements exceed the given key.public static <T> int lowerBound(T[] a, T key, int imin, int imax, Comparator<T> comparator)
T
 the type of elements in arraya
 array that holds the valueskey
 element to look forimin
 the minimal index (inclusive) to look forimax
 the maximum index (inclusive) to look forcomparator
 comparator that compares keysa.length
when all
elements are less than the given key.public static <T> int upperBound(T[] a, T key, int imin, int imax, Comparator<T> comparator)
T
 the type of elements in arraya
 array that holds the valueskey
 element to look forimin
 the minimal index (inclusive) to look forimax
 the maximum index (inclusive) to look forcomparator
 comparator that compares keysa.length
when
all elements exceed the given key.public static <T,K> int lowerBound(T[] a, K key, int imin, int imax, Function1<T,K> keySelector, Comparator<K> comparator)
public static <T,K> int upperBound(T[] a, K key, int imin, int imax, Function1<T,K> keySelector, Comparator<K> comparator)
Copyright © 2012–2017 The Apache Software Foundation. All rights reserved.