1: // Created by Frank M. Carrano and Timothy M. Henry.
2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.
4: template<class ItemType>
5: Node<ItemType>* LinkedList<ItemType>::getNodeAt(int position) const
6: {
7: // Debugging check of precondition
8: assert( (position >= 1) && (position <= itemCount) );
9:
10: // Count from the beginning of the chain
11: Node<ItemType>* curPtr = headPtr;
12: for (int skip = 1; skip < position; skip++)
13: curPtr = curPtr->getNext();
14:
15: return curPtr;
16: } // end getNodeAt