src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
/**
     * Simple binary search for a given column name.
     * The return value has the exact same meaning that the one of Collections.binarySearch().
     * (We don't use Collections.binarySearch() directly because it would require us to create
     * a fake IColumn (as well an IColumn comparator) to do the search, which is ugly.
     */
Simple binary search for a given column name.
The return value has the exact same meaning that the one of Collections.binarySearch().
(We don't use Collections.binarySearch() directly because it would require us to create
a fake IColumn (as well an IColumn comparator) to do the search, which is ugly.
Simple binary search for a given column name . The return value has the exact same meaning that the one of Collections . binarySearch () . ( We don ' t use Collections . binarySearch () directly because it would require us to create a fake IColumn ( as well an IColumn comparator ) to do the search which is ugly .
private int binarySearch(ByteBuffer name)
    {
        int low = 0;
        int mid = size();
        int high = mid - 1;
        int result = -1;
        while (low <= high)
        {
            mid = (low + high) >> 1;
            if ((result = compare(name, columns.get(mid).name())) > 0)
            {
                low = mid + 1;
            }
            else if (result == 0)
            {
                return mid;
            }
            else
            {
                high = mid - 1;
            }
        }
        return -mid - (result < 0 ? 1 : 2);
    }
private int binarySearch ( ByteBuffer name ) { int low = 0 ; int mid = size ( ) ; int high = mid - 1 ; int result = - 1 ; while ( low <= high ) { mid = ( low + high ) >> 1 ; if ( ( result = compare ( name , columns . get ( mid ) . name ( ) ) ) > 0 ) { low = mid + 1 ; } else if ( result == 0 ) { return mid ; } else { high = mid - 1 ; } } return - mid - ( result < 0 ? 1 : 2 ) ; }
Simple binary search for a given column name.
Simple binary search for a given column name .