doubly linked list

Doubly linked list insertAt:
node.next = curr;
node.prev = curr.prev;
curr.prev = node;

if (curr.prev) {
curr.prev.next = node;
}
node.next = curr;
node.prev = curr.prev;
curr.prev = node;

if (curr.prev) {
curr.prev.next = node;
}
I'm kinda of confused about the inserting of a new node here and links. Lets say we have A->B and I insert G so, curr = B G.next = B G.prev = A all fine but now: curr.prev = G then if we are doing curr.prev.next, wont that be B.next = G??? ERRR! Or in the memory the link is there and it's acutally A.next = G
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?