Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DNode {
- // Node for building a Doubly-linked list
- String contents;
- DNode next;
- DNode prev;
- DNode (String k) { // Constructor: builds a node which can be searched forwards and backwards
- next= null; prev= null;
- contents= k;
- }
- DNode (String k, DNode prev, DNode next){ // Constructor: builds a node with given references
- this.prev = prev;
- this.next = next;
- this.contents = k;
- }
- 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.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement