1: // @author Frank M. Carrano, Timothy M. Henry
2: // @version 5.0
3: public T[] toArray()
4: {
5: // The cast is safe because the new array contains null entries
6: @SuppressWarnings("unchecked")
7: T[] result = (T[])new Object[numberOfEntries];
8:
9: int index = 0;
10: Node currentNode = firstNode;
11: while ((index < numberOfEntries) && (currentNode != null))
12: {
13: result[index] = currentNode.getData();
14: currentNode = currentNode.getNextNode();
15: index++;
16: } // end while
17:
18: return result;
19: } // end toArray