1: /**
2: An abstract base class for use in implementing the ADT list
3: by using a chain of nodes. All methods are implemented, but
4: since the class is abstract, no instances can be created.
5:
6: @author Frank M. Carrano
7: @author Timothy M. Henry
8: @author Charles Hoot
9: @version 5.0
10: */
11: public abstract class LinkedChainBase<T>
12: {
13: private Node firstNode; // Reference to first node
14: private int numberOfEntries;
16: public LinkedChainBase()
17: {
18: initializeDataFields();
19: } // end default constructor
21: /* < Implementations of the public methods clear, getLength, isEmpty, and toArray go here. >
22: . . .
23:
24: < Implementations of the protected, final methods getFirstNode, addFirstNode,
25: addAfterNode, removeFirstNode, removeAfterNode, getNodeAt, and
26: initializeDataFields go here. >
27: . . . */
29: protected final class Node
30: {
31: private T data; // Entry in list
32: private Node next; // Link to next node
34: protected Node(T dataPortion)
35: {
36: data = dataPortion;
37: next = null;
38: } // end constructor
40: private Node(T dataPortion, Node nextNode)
41: {
42: data = dataPortion;
43: next = nextNode;
44: } // end constructor
46: /* < Implementations of the protected methods getData, setData, and getNextNode go here. >
47: . . .
48:
49: < Implementation of the private method setNextNode goes here. >
50: . . . */
51: } // end Node
52: } // end LinkedChainBase