public final int findSegmentIndex(int offset) {
    if (mySegmentCount <= 0) {
      return offset == 0 ? 0 : noSegmentsAvailable(offset);
    }

    final int lastValidOffset = getLastValidOffset();
    if (offset > lastValidOffset || offset < 0) {
      return offsetOutOfRange(offset, lastValidOffset);
    }

    int end = mySegmentCount - 1;
    if (offset == lastValidOffset) {
      return end;
    }

    int start = 0;
    while (start <= end) {
      int i = (start + end) >>> 1;
      if (offset < myStarts[i]) {
        end = i - 1;
      }
      else if (offset >= myEnds[i]) {
        start = i + 1;
      }
      else {
        return i;
      }
    }

    return segmentNotFound(offset, start);
  }
public final int findSegmentIndex(int offset)