positions.add(index, pos);
positions.add(index, r);
  public Position createPosition(final int offset) throws BadLocationException  {    if (offset < 0 || offset > length())      throw new BadLocationException("The offset was out of the bounds of this"          + " buffer", offset);    // We store the actual array index in the GapContentPosition. The real    // offset is then calculated in the GapContentPosition.    int mark = offset;    if (offset >= gapStart)      mark += gapEnd - gapStart;    GapContentPosition pos = new GapContentPosition(mark);    // Add this into our list in a sorted fashion.    int index = Collections.binarySearch(positions, pos);    if (index < 0)      index = -(index + 1);    positions.add(index, pos);    return pos;  }