public int getNextRangeIndex(byte[] rowKey) {
      BasicRowRange temp;
      if (reversed) {
        temp = new ReversedRowRange(null, true, rowKey, true);
      } else {
        temp = new RowRange(rowKey, true, null, true);
      }
      // Because we make sure that `ranges` has the correct natural ordering (given it containing
      // RowRange or ReverseRowRange objects). This keeps us from having to have two different
      // implementations below.
      final int index = Collections.binarySearch(ranges, temp);
      if (index < 0) {
        int insertionPosition = -index - 1;
        // check if the row key in the range before the insertion position
        if (insertionPosition != 0 && ranges.get(insertionPosition - 1).contains(rowKey)) {
          return insertionPosition - 1;
        }
        // check if the row key is before the first range
        if (insertionPosition == 0 && !ranges.get(insertionPosition).contains(rowKey)) {
          return ROW_BEFORE_FIRST_RANGE;
        }
        if (!foundFirstRange) {
          foundFirstRange = true;
        }
        return insertionPosition;
      }
      // the row key equals one of the start keys, and the the range exclude the start key
      if (ranges.get(index).isSearchRowInclusive() == false) {
        exclusive = true;
      }
      return index;
    }
Calculates the position where the given rowkey fits in the ranges list.
@param rowKey the row key to calculate
@return index the position of the row key
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java