Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void insertAfter(DNode curr, DNode newNode) { //TODO
- // Pre: curr and newNode are addresses for DNodes
- // Post: newNode is inserted between curr and its next neighbour, i.e.
- // let N be newNode's next neighbour, then: curr.next points to newNode, newNode.next points to N
- // N.prev points to newNode and newNode.prev points to curr.
- // If curr has no next neighbour, then newNode is inserted as the last node after curr.
- DNode n = curr.next; //Since the neighbor of the element being inserted will be this nodes next element.
- curr.next = newNode;
- newNode.next = n;
- n.prev = newNode;
- newNode.prev = curr;
- if (curr.next.contents == null){
- curr.next = new DNode(newNode.contents);
- }
- //This is where I am lost. :/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement