|
|
 |
|
|
|
|
151: }
152:
153:
154: // Tail node is just a sentinel
155: template <class T>
156: class TailNode : public Node<T>
157: {
158: public:
159: TailNode(){}
160: virtual ~TailNode(){}
161: virtual Node<T> * Insert(T * theObject);
162: virtual void Show() {}
163:
164: private:
165:
166: };
167:
168: // If Object comes to me, it must be inserted before me
169: // as I am the tail and NOTHING comes after me
170: template <class T>
171: Node<T> * TailNode<T>::Insert(T * theObject)
172: {
173: InternalNode<T> * ObjectNode =
174: new InternalNode<T>(theObject, this);
175: return ObjectNode;
176: }
177:
178: // Head node has no Object, it just points
179: // to the very beginning of the list
180: template <class T>
181: class HeadNode : public Node<T>
182: {
183: public:
184: HeadNode();
185: virtual ~HeadNode() { delete myNext; }
186: virtual Node<T> * Insert(T * theObject);
187: virtual void Show() { myNext->Show(); }
188: private:
189: Node<T> * myNext;
190: };
191:
192: // As soon as the head is created
193: // it creates the tail
194: template <class T>
195: HeadNode<T>::HeadNode()
196: {
197: myNext = new TailNode<T>;
198: }
199: |
|
|
|
 |
|
|
|
|
continues |
|
|
|
|
|