These notes are intended to help describe Homework #5. The list below shows the head_node, last_node, and count fields of the list object. The actual list nodes are allocated on the heap using 'new'. They are linked from one to the next (top to bottom in the diagram below). The figure also shows an iterator object named 'it'. The iterator points at the node holding the value 30. Its internal previous pointer points at the pervious node in the list. All iterator operations are supposed to maintain this relationship (and still be constant time) head_node --> 10 20 <- it.previous 30 <- it.current last_node --> 40 count == 4 If a list is empty the head_node and last_node pointers are both nullptr (and count is zero, of course). If the list contains one item head_node and last_node point at the same node. The diagram below shows what happens after using insert( it, 25 ). The iterator is still left pointing at the node holding 30. However, the iterator's previous pointer has been changed to reference the freshly added node. Notice also that the count has been updated. To do this the it.object pointer must be used to locate the object into which the iterator points. head_node --> 10 20 25 <- it.previous 30 <- it.current last_node --> 40 count == 5 You can tell by looking at an iterator if it is in a special location. Specifically: if 'it' points just past the end, then it.current is nullptr, and if 'it' points at the first item, then it.previous is nullptr. The diagram below shows the first list with 'it' pointing at the first element. it.previous == nullptr head_node --> 10 <- it.current 20 30 last_node --> 40 count == 4 The diagram below shows the effect of calling insert( it, 5 ). The iterator continues to point at the node holding 10. However, it.previous has been changed to point at the freshly inserted node. Notice that (in addition to 'count') the head_node pointer has been changed to point at the new head node. head_node --> 5 <- it.previous 10 <- it.current 20 30 last_node --> 40 count == 5