From 20c4be47a39b6d8e7bb1587a8a4630bb2e620f54 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 26 May 2006 17:18:23 +0000 Subject: add functions for reverse iteration of Common::List svn-id: r22665 --- common/list.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'common') diff --git a/common/list.h b/common/list.h index d7273295e0..38ba9b143b 100644 --- a/common/list.h +++ b/common/list.h @@ -174,6 +174,18 @@ public: return iterator(next); } + iterator reverse_erase(iterator pos) { + assert(pos != end()); + + NodeBase *next = pos._node->_next; + NodeBase *prev = pos._node->_prev; + Node *node = static_cast *>(pos._node); + prev->_next = next; + next->_prev = prev; + delete node; + return iterator(prev); + } + iterator erase(iterator first, iterator last) { while (first != last) erase(first++); @@ -229,6 +241,10 @@ public: return iterator(_anchor->_next); } + iterator reverse_begin() { + return iterator(_anchor->_prev); + } + iterator end() { return iterator(_anchor); } @@ -237,6 +253,10 @@ public: return const_iterator(_anchor->_next); } + const_iterator reverse_begin() const { + return const_iterator(_anchor->_prev); + } + const_iterator end() const { return const_iterator(_anchor); } -- cgit v1.2.3