insertAfter method

VertexList insertAfter(
  1. VertexNode target,
  2. VertexNode vertex
)

Implementation

VertexList insertAfter(VertexNode target, VertexNode vertex) {
  vertex.prev = target;
  vertex.next = target.next;

  if (vertex.next == null) {
    tail = vertex;
  } else {
    vertex.next!.prev = vertex;
  }

  target.next = vertex;

  return this;
}