00001 00042 #ifndef _LINKEDLIST_H 00043 #define _LINKEDLIST_H 00044 00045 #include "list.h" 00046 00047 using std::ostream; 00048 00049 namespace container { 00050 00057 class LinkedList: public virtual List { 00058 public: 00059 00060 const static Info* const TYPE_INFO; 00061 00062 protected: 00063 00064 class Node; 00065 00071 Node* current; 00072 00080 Node* head; 00081 00089 Node* tail; 00090 00097 LinkedList(); 00098 00106 LinkedList(const LinkedList& pattern); 00107 00108 public: 00109 00115 virtual ~LinkedList(); 00116 00117 protected: 00118 00119 /********************* LinkedList Methods (protected) *********************/ 00120 00125 virtual bool toNext(Node*& cursor); 00126 00127 public: 00128 00129 /********************* List Methods (public) *********************/ 00130 00131 virtual bool isFirst() const; 00132 00133 virtual bool isLast() const; 00134 00135 virtual bool isTail() const; 00136 00137 virtual bool toFirst(); 00138 00139 virtual bool toLast(); 00140 00141 virtual void toTail(); 00142 00143 virtual bool toNext(); 00144 00145 virtual bool toPrev(); 00146 00147 virtual Entity * currentEntity(); 00148 00149 virtual void locateEntity(const Entity &key, int &index, Entity* &entity); 00150 00151 virtual Entity* entityAt(int index); 00152 00153 protected: 00154 00155 /********************* List Methods (protected) *********************/ 00156 00157 virtual bool deleteCurrent_impl(); 00158 00159 virtual Entity * extractCurrentEntity_impl(); 00160 00161 public: 00162 00163 /********************* Object Methods (public) *********************/ 00164 00165 virtual ostream& renderState(ostream& os) const; 00166 00167 virtual const Info* typeInfo() const; 00168 00169 // virtual Object* clone(bool deepCopy = false) const = 0; 00170 00171 }; 00172 00173 /********************* Nested class LinkedList::Node *********************/ 00174 00187 class LinkedList::Node { 00188 public: 00189 00190 Node* next; 00191 Node* prev; 00192 Entity* entity; 00193 00194 Node(); 00195 00206 Node(Entity *e, Node *n); 00207 00208 ~Node(); 00209 00210 Entity * extractEntity(); 00211 00212 }; 00213 00214 } // namespace container 00215 #endif /* _LINKEDLIST_H */