Ticket #8839: list2.patch
File list2.patch, 1.5 KB (added by , 17 years ago) |
---|
-
common/list.h
26 26 #define COMMON_LIST_H 27 27 28 28 #include "common/scummsys.h" 29 #include "common/noncopyable.h" 29 30 30 31 namespace Common { 31 32 … … 133 134 insert(begin(), list.begin(), list.end()); 134 135 } 135 136 136 ~List() {137 virtual ~List() { 137 138 clear(); 138 139 delete _anchor; 139 140 } … … 161 162 insert(pos, *first); 162 163 } 163 164 164 iterator erase(iterator pos) {165 virtual iterator erase(iterator pos) { 165 166 assert(pos != end()); 166 167 167 168 NodeBase *next = pos._node->_next; … … 173 174 return iterator(next); 174 175 } 175 176 176 iterator reverse_erase(iterator pos) {177 virtual iterator reverse_erase(iterator pos) { 177 178 assert(pos != end()); 178 179 179 180 NodeBase *next = pos._node->_next; … … 261 262 } 262 263 }; 263 264 265 template<class T> 266 class ManagedList : public List<T*>, public NonCopyable { 267 typedef List<T*> Base; 268 public: 269 typedef typename List<T*>::iterator iterator; 270 typedef typename List<T*>::const_iterator const_iterator; 271 typedef typename List<T*>::value_type value_type; 272 273 iterator erase(iterator pos) { 274 if (pos != Base::end()) 275 delete *pos; 276 return Base::erase(pos); 277 } 278 279 iterator extract(iterator pos) { 280 return Base::erase(pos); 281 } 282 283 iterator reverse_erase(iterator pos) { 284 if (pos != Base::end()) 285 delete *pos; 286 return Base::reverse_erase(pos); 287 } 288 289 iterator reverse_extract(iterator pos) { 290 return Base::reverse_erase(pos); 291 } 292 }; 293 264 294 } // End of namespace Common 265 295 266 296 #endif