public int binarySearch ( RowPosition key ) { int low = 0 , mid = offsetCount , high = mid - 1 , result = - 1 ; while ( low <= high ) { mid = ( low + high ) >> 1 ; result = - DecoratedKey . compareTo ( partitioner , ByteBuffer . wrap ( getKey ( mid ) ) , key ) ; if ( result > 0 ) { low = mid + 1 ; } else if ( result == 0 ) { return mid ; } else { high = mid - 1 ; } } return - mid - ( result < 0 ? 1 : 2 ) ; }
Harmony s Collections implementation