append method

VertexList append(
  1. VertexNode vertex
)

Implementation

VertexList append(VertexNode vertex) {
  if (head == null) {
    head = vertex;
  } else {
    tail!.next = vertex;
  }

  vertex.prev = tail;
  vertex.next = null; // the tail has no subsequent vertex

  tail = vertex;

  return this;
}