add33 method

void add33(
  1. int i,
  2. Coordinate coord,
  3. bool allowRepeated
)

Inserts the specified coordinate at the specified position in this list.

@param i the position at which to insert @param coord the coordinate to insert @param allowRepeated if set to false, repeated coordinates are collapsed

Implementation

void add33(int i, Coordinate coord, bool allowRepeated) {
  // don't add duplicate coordinates
  if (!allowRepeated) {
    int size = _backingList.length;
    if (size > 0) {
      if (i > 0) {
        Coordinate prev = _backingList[i - 1];
        if (prev.equals2D(coord)) return;
      }
      if (i < size) {
        Coordinate next = _backingList[i];
        if (next.equals2D(coord)) return;
      }
    }
  }
  _backingList.insert(i, coord);
}