if (p.index > start || p.index <= end) p.index = start; else if (p.index > end)
if (p.index > startIndex || p.index <= endIndex) p.index = startIndex; else if (p.index > endIndex)
  private void setPositionsInRange(int start, int end, boolean toStart)  {    // We slump together all the GapContentPositions to point to    // one mark. So this is implemented as follows:    // 1. Remove all the marks in the specified range.    // 2. Insert one new mark at the correct location.    // 3. Adjust all affected GapContentPosition instances to point to    //    this new mark.    synchronized (this)      {        int startIndex = binarySearch(positionMarks, start, numMarks);        if (startIndex < 0) // Translate to insertion index, if not found.          startIndex = - startIndex - 1;        int endIndex = binarySearch(positionMarks, end, numMarks);        if (endIndex < 0) // Translate to insertion index - 1, if not found.          endIndex = - endIndex - 2;        // Update the marks.        // We have inclusive interval bounds, but let one element over for        // filling in the new value.        int removed = endIndex - startIndex;        if (removed <= 0)          return;        System.arraycopy(positionMarks, endIndex + 1, positionMarks,                         startIndex + 1, positionMarks.length - endIndex - 1);        numMarks -= removed;        if (toStart)  {            positionMarks[startIndex] = start;          }        else          {            positionMarks[startIndex] = end;      }        // Update all affected GapContentPositions to point to the new index        // and all GapContentPositions that come after the interval to        // have their index moved by -removed.        Set positionSet = positions.keySet();        for (Iterator i = positionSet.iterator(); i.hasNext();)      {            GapContentPosition p = (GapContentPosition) i.next();            if (p.index > start || p.index <= end)              p.index = start;            else if (p.index > end)              p.index -= removed;          }  }  }