Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void addNewNode(DNode newNode) { //TODO
- // Post: newNode is inserted into the current list in correct sorted order
- // numNodes is adjusted to be equal to the number of nodes in the list
- ArrayList<String> ar = new ArrayList<String>();
- for (int i = 0; i < numNodes; i++){
- ar.add(lastVisited.contents);
- lastVisited = lastVisited.next;
- }
- lastVisited = head; //reset to head - start setting the values
- ar.add(newNode.contents);
- Collections.sort(ar);
- numNodes = ar.size()+1;
- for (int x = 0; x < numNodes; x++){
- lastVisited.contents = ar.get(x); // <-------
- lastVisited = lastVisited.next;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement