rcm.util
Class BinarySearch

java.lang.Object
  |
  +--rcm.util.BinarySearch

public abstract class BinarySearch
extends java.lang.Object

Binary search routines.


Field Summary
static Debug debug
           
 
Constructor Summary
BinarySearch()
           
 
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
 

Field Detail

debug

public static Debug debug
Constructor Detail

BinarySearch

public BinarySearch()
Method Detail

search

public static int search(int[] array,
                         int offset,
                         int length,
                         int x)
Search a sorted array of integers.

Parameters:
array - Array of integers
offset - Starting offset of subarray to search
length - Length of subarray to search
x - 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.