I'm having trouble understanding the second half of connecting a new node into a double-linked list. I'm writing an add method that takes in the node which the new node is to be inserted after. My area of difficulty is understanding how to link to the next node after the previous node links have been re-directed to the new node.
So, here's where I've come up with
Chunk<E> newChunk= new Chunk<E>();
newChunk.next= prevChunk.next;
prevChunk.next= newChunk;
newChunk.prev= newChunk.next.prev;
newChunk.next.prev= newChunk;
My understanding is since the newChunk.next= prevChunk.next
command copies the memory address of prevChunk.next and sets that value into newChunk.next, and then the prevChunk.next is reset to link to the newChunk.
So since the prevChunk is the only node referenced here that is already in the list, and the next fields have been re-routed to the newChunk, am I on the right track in using those references to link to the next node?