Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1.  
  2. class DNode {
  3. // Node for building a Doubly-linked list
  4.     String contents;
  5.     DNode next;
  6.     DNode prev;
  7.    
  8.     DNode (String k) {  // Constructor: builds a node which can be searched forwards and backwards
  9.         next= null; prev= null;
  10.         contents= k;       
  11.     }
  12.    
  13.     DNode (String k, DNode prev, DNode next){ // Constructor: builds a node with given references
  14.         this.prev = prev;
  15.         this.next = next;
  16.         this.contents = k;
  17.     }
  18.  
  19.     void insertAfter(DNode curr, DNode newNode) { //TODO
  20.         // Pre: curr and newNode are addresses for DNodes
  21.         // Post: newNode is inserted between curr and its next neighbour, i.e.
  22.         // let N be newNode's next neighbour, then: curr.next points to newNode, newNode.next points to N
  23.         // N.prev points to newNode and newNode.prev points to curr.
  24.         // If curr has no next neighbour, then newNode is inserted as the last node after curr.
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement