lapisx.util
Class BinarySearch
java.lang.Object
lapisx.util.BinarySearch
- public abstract class BinarySearch
- extends Object
Binary search routines.
Method Summary |
static int |
search(int[] array,
int offset,
int length,
int x)
Search a sorted array of integers. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
debug
public static Debug debug
BinarySearch
public BinarySearch()
search
public static int search(int[] array,
int offset,
int length,
int x)
- Search a sorted array of integers.
- Parameters:
array
- Array of integersoffset
- Starting offset of subarray to searchlength
- Length of subarray to searchx
- Value to search for
- Returns:
- largest index i in subarray (offset <= i <= offset+length)
such that all elements below i in the subarray are strictly less
than x. If x is found in the subarray, then array[i] == x (and i is
the first occurence of x in the subarray). If x is not found,
then array[i] is where x should be inserted in the sort order.