Class IntBinarySearch
- java.lang.Object
-
- org.magicwerk.brownies.collections.helper.primitive.IntBinarySearch
-
public class IntBinarySearch extends java.lang.Object
Binary search for primitive type int.
-
-
Constructor Summary
Constructors Constructor Description IntBinarySearch()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
binarySearch(IIntList list, int key, int lower, int upper)
Searches the specified list for the specified object using the binary search algorithm.
-
-
-
Method Detail
-
binarySearch
public static int binarySearch(IIntList list, int key, int lower, int upper)
Searches the specified list for the specified object using the binary search algorithm. The list must be sorted into ascending order according to the specified comparator (as by theCollections.sort(List, Comparator)
method), prior to making this call. If it is not sorted, the results are undefined.This method runs in log(n) time on random-access lists, which offer near-constant-time access to each list element.
- Parameters:
list
- the list to be searched.key
- the value to be searched for.lower
- lower bound of range to searchupper
- upper bound of range to search- Returns:
- the index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1).
-
-