}//end insertNode() private Node findInsertionPoint(Node temp) { //define Insertion Point as the node after which temp should be inserted Node current = headFirstName; if (headFirstName.getFirstName().CompareTo(temp.getFirstName()) > 0) { return(null); } while (current.getFirstName().CompareTo(temp.getFirstName()) < 0) { if (null == current.nextFirstName) { return(current); } else { current = current.nextFirstName; } } return(current.prevFirstName); }//end findInsertionPoint()
}//end addNode() private Node findNode(String findItem) { Node current = headFirstName; while (current.getFirstName().CompareTo(findItem) != 0) //names don't match { if (null == current.nextFirstName) //reached the end of the list { return(null); //findItem is not in the list } current = current.nextFirstName; //found the match } return(current); }//end findNode()
}//end findLastNode() public String showAllNodes() { String nodeList = ""; Node current = headFirstName; if (null == headFirstName) { return("there are no nodes on this list"); } while (current != null) { nodeList += current.getFirstName() + "\n"; current = current.nextFirstName; } return(nodeList); }//end showAllNodes