1: // Returns a reference to the node at a given position.
2: // Precondition: The chain is not empty;
3: // 1 <= givenPosition <= numberOfEntries.
4: // @author Frank M. Carrano, Timothy M. Henry
5: // @version 5.0
6: private Node getNodeAt(int givenPosition)
7: {
8: // Assertion: (firstNode != null) &&
9: // (1 <= givenPosition) && (givenPosition <= numberOfEntries)
10: Node currentNode = firstNode;
11: // Traverse the chain to locate the desired node
12: // (skipped if givenPosition is 1)
13: for (int counter = 1; counter < givenPosition; counter++)
14: currentNode = currentNode.getNextNode();
15: // Assertion: currentNode != null
16: return currentNode;
17: } // end getNodeAt