1: // @author Frank M. Carrano, Timothy M. Henry
2: // @version 5.0
3: // Finds the node that is before the node that should or does
4: // contain a given entry.
5: // Returns either a reference to the node that is before the node
6: // that contains--or should contain--anEntry, or null if no prior node exists
7: // (that is, if anEntry is or belongs at the beginning of the list).
8: private Node getNodeBefore(T anEntry)
9: {
10: Node currentNode = firstNode;
11: Node nodeBefore = null;
13: while ( (currentNode != null) &&
14: (anEntry.compareTo(currentNode.getData()) > 0) )
15: {
16: nodeBefore = currentNode;
17: currentNode = currentNode.getNextNode();
18: } // end while
20: return nodeBefore;
21: } // end getNodeBefore