insert method

void insert(
  1. int x,
  2. int y,
  3. NodeOutput item
)

Implementation

void insert(int x, int y, NodeOutput item) {
  if (this.height() <= y) {
    this.extendHeight(y + 1);
  }
  if (this.width() <= x) {
    this.extendWidth(x + 1);
  }
  final current = s[y][x];
  if (current == null) {
    this.s[y][x] = !item.isAnchor
        ? MatrixCell(full: item)
        : (item.anchorMargin! == AnchorMargin.end
            ? MatrixCell(end: item)
            : MatrixCell(start: item));
    return;
  }
  if (!current.isFull &&
      current.margin != null &&
      current.margin != item.anchorMargin) {
    current.add(item);
  }
}