1: // Makes room for a new entry at newPosition.
2: // Precondition: 1 <= newPosition <= numberOfEntries + 1;
3: // numberOfEntries is list's length before addition;
4: // checkInitialization has been called.
5: private void makeRoom(int newPosition)
6: {
7: assert (newPosition >= 1) && (newPosition <= numberOfEntries + 1);
8: int newIndex = newPosition;
9: int lastIndex = numberOfEntries;
10: // Move each entry to next higher index, starting at end of
11: // list and continuing until the entry at newIndex is moved
12: for (int index = lastIndex; index >= newIndex; index--)
13: list[index + 1] = list[index];
14: } // end makeRoom
15: // Version 4.0