An error in LinkedList implementation in Chapter 6

  1. The function copyNodes(returningCopyOf node: Node<Value>?) should return the node itself, not nil when copy is not performed. Otherwise, the node is not removed from the list.
  2. The insertion function, should use copyNodes(returningCopyOf node: Node<Value>?) instead of regular copyNodes() for the same reason, remove does.
  3. This is trickier to correct, and I believe requires different approach to COW - when performing operations on the first node - we create additional reference to head, which forces copy to be performed, even when data structure itself is not really copied.

A correction in the source code would be greatly appreciated.