int index1 = Collections.binarySearch(positions, new GapContentPosition(offset), new WeakPositionComparator()); if (index1 < 0) index1 = -(index1 + 1);
synchronized (this) {  int startIndex = binarySearch(positionMarks, offset, numMarks); if (startIndex < 0) startIndex = - startIndex - 1; int endIndex = binarySearch(positionMarks, endMark, numMarks); if (endIndex < 0) endIndex = - endIndex - 2;
  private void adjustPositionsInRange(int offset, int length, int incr)  {    int endOffset = offset + length;    int index1 = Collections.binarySearch(positions,                                          new GapContentPosition(offset),                                          new WeakPositionComparator());    if (index1 < 0)      index1 = -(index1 + 1);    // Search the first index with the specified offset. The binarySearch does    // not necessarily find the first one.    while (index1 > 0)      {        WeakReference r = (WeakReference) positions.get(index1 - 1);        GapContentPosition p = (GapContentPosition) r.get();        if (p != null && p.mark == offset || p == null)      index1--;        else          break;      }    for (ListIterator i = positions.listIterator(index1); i.hasNext();)      {        WeakReference r = (WeakReference) i.next();        GapContentPosition p = (GapContentPosition) r.get();        if (p == null)          continue;        if (p.mark > endOffset)          break;                if (p.mark >= offset && p.mark <= endOffset)          p.mark += incr;      }  }