aboutsummaryrefslogtreecommitdiff
path: root/common/list.h
diff options
context:
space:
mode:
authorMax Horn2004-05-08 19:34:06 +0000
committerMax Horn2004-05-08 19:34:06 +0000
commit7804b57632e3e4eb57971f2a95fa873ef11866ea (patch)
tree283119133680f257b5f8d16b458f65df3ba1a885 /common/list.h
parent011173f18c0d32f63b76222105880cd67dc3f2d2 (diff)
downloadscummvm-rg350-7804b57632e3e4eb57971f2a95fa873ef11866ea.tar.gz
scummvm-rg350-7804b57632e3e4eb57971f2a95fa873ef11866ea.tar.bz2
scummvm-rg350-7804b57632e3e4eb57971f2a95fa873ef11866ea.zip
Added default iterator constructor, for convenience
svn-id: r13808
Diffstat (limited to 'common/list.h')
-rw-r--r--common/list.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/common/list.h b/common/list.h
index b21bc5e862..2e8403c9dc 100644
--- a/common/list.h
+++ b/common/list.h
@@ -50,31 +50,37 @@ protected:
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 {