[Scummvm-cvs-logs] CVS: scummvm/common list.h,1.16,1.17

Max Horn fingolfin at users.sourceforge.net
Sat May 8 12:35:01 CEST 2004


Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32519

Modified Files:
	list.h 
Log Message:
Added default iterator constructor, for convenience

Index: list.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/list.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- list.h	16 Apr 2004 22:04:32 -0000	1.16
+++ list.h	8 May 2004 19:34:06 -0000	1.17
@@ -50,31 +50,37 @@
 	struct Iterator {
 		NodeBase *_node;
 		
+		Iterator<T2>() : _node(0) {}
 		Iterator<T2>(NodeBase *node) : _node(node) {}
 
 		// Prefix inc
 		Iterator<T2> &operator++() {
-			_node = _node->_next;
+			if (_node)
+				_node = _node->_next;
 			return *this;
 		}
 		// Postfix inc
 		Iterator<T2> operator++(int) {
 			Iterator<T2> tmp = *this;
-			_node = _node->_next;
+			if (_node)
+				_node = _node->_next;
 			return tmp;
 		}
 		// Prefix dec
 		Iterator<T2> &operator--() {
-			_node = _node->_prev;
+			if (_node)
+				_node = _node->_prev;
 			return *this;
 		}
 		// Postfix dec
 		Iterator<T2> operator--(int) {
 			Iterator<T2> tmp = *this;
-			_node = _node->_prev;
+			if (_node)
+				_node = _node->_prev;
 			return tmp;
 		}
 		T2& operator*() const {
+			assert(_node);
 			return static_cast<Node<T2>*>(_node)->_data;
 		}
 		T2* operator->() const {





More information about the Scummvm-git-logs mailing list