public class LinkedBag
1: /** OUTLINE
2: A class of bags whose entries are stored in a chain of linked nodes.
3: The bag is never full.
4: @author Frank M. Carrano
5: @version 4.0
6: */
7: public class LinkedBag<T> implements BagInterface<T>
8: {
9: private Node firstNode; // reference to first node
10: private int numberOfEntries;
11:
12: public LinkedBag()
13: {
14: firstNode = null;
15: numberOfEntries = 0;
16: } // end default constructor
17:
18: // . . .
19:
20: private class Node
21: {
22: private T data; // Entry in bag
23: private Node next; // Link to next node
24:
25: private Node(T dataPortion)
26: {
27: this(dataPortion, null);
28: } // end constructor
29:
30: private Node(T dataPortion, Node nextNode)
31: {
32: data = dataPortion;
33: next = nextNode;
34: } // end constructor
35: } // end Node
36: } // end LinkedBag