static int binarySearch(long keys[], int start, int len, long key) {
        int high = start + len, low = start - 1, guess;
        while (high - low > 1) {
            // use >>> for average or we could get an integer overflow.
            guess = (high + low) >>> 1;
            long guessedKey = keys[guess];
            if (guessedKey < key) {
                low = guess;
            } else {
                high = guess;
            }
        }

        if (high == start + len) {
            return ~(start + len);
        }

        long highKey = keys[high];
        if (highKey == key) {
            return high;
        } else {
            return ~high;
        }
    }
static int binarySearch ( long keys [ ] , int start , int len , long key ) { int high = start + len , low = start - 1 , guess ; while ( high - low > 1 ) { guess = ( high + low ) > > > 1 ; long guessedKey = keys [ guess ] ; if ( guessedKey < key ) { low = guess ; } else { high = guess ; } } if ( high == start + len ) { return ~ ( start + len ) ; } long highKey = keys [ high ] ; if ( highKey == key ) { return high ; } else { return ~ high ; } }
LATER: see OSMIDMap for a version where we use DataAccess