# Ticket #9278: ReverseIterator.patch

File ReverseIterator.patch, 1.8 KB (added by SF/nicogarnier, 13 years ago)
• ## common/list_intern.h

 }; template struct ReverseIterator { typedef ReverseIterator      Self; typedef Node *       NodePtr; typedef T &                     ValueRef; typedef T *                     ValuePtr; typedef T                       ValueType; NodeBase *_node; ReverseIterator() : _node(0) {} explicit ReverseIterator(NodeBase *node) : _node(node) {} // Prefix inc Self &operator++() { if (_node) _node = _node->_prev; return *this; } // Postfix inc Self operator++(int) { Self tmp(_node); ++(*this); return tmp; } // Prefix dec Self &operator--() { if (_node) _node = _node->_next; return *this; } // Postfix dec Self operator--(int) { Self tmp(_node); --(*this); return tmp; } ValueRef operator*() const { assert(_node); return static_cast(_node)->_data; } ValuePtr operator->() const { return &(operator*()); } bool operator==(const Self &x) const { return _node == x._node; } bool operator!=(const Self &x) const { return _node != x._node; } }; template struct ConstIterator { typedef ConstIterator        Self; typedef const Node * NodePtr; bool operator!=(const Iterator& a, const ConstIterator& b) { return a._node != b._node; } template bool operator==(const ReverseIterator& a, const ConstIterator& b) { return a._node == b._node; } template bool operator!=(const ReverseIterator& a, const ConstIterator& b) { return a._node != b._node; } }