insertNode function

Node insertNode(
  1. int i,
  2. double x,
  3. dynamic y,
  4. Node? last,
)

Implementation

Node insertNode(int i, double x, y, Node? last) {
  Node p = Node(i, x, y);

  if (last == null) {
    p.prev = p;
    p.next = p;
  } else {
    p.next = last.next;
    p.prev = last;
    last.next?.prev = p;
    last.next = p;
  }

  return p;
}