| 105 | struct ReverseIterator { |

| 106 | typedef ReverseIterator<T> Self; |

| 107 | typedef Node<T> * NodePtr; |

| 108 | typedef T & ValueRef; |

| 109 | typedef T * ValuePtr; |

| 110 | typedef T ValueType; |

| 111 | |

| 112 | NodeBase *_node; |

| 113 | |

| 114 | ReverseIterator() : _node(0) {} |

| 115 | explicit ReverseIterator(NodeBase *node) : _node(node) {} |

| 116 | |

| 117 | // Prefix inc |

| 118 | Self &operator++() { |

| 119 | if (_node) |

| 120 | _node = _node->_prev; |

| 121 | return *this; |

| 122 | } |

| 123 | // Postfix inc |

| 124 | Self operator++(int) { |

| 125 | Self tmp(_node); |

| 126 | ++(*this); |

| 127 | return tmp; |

| 128 | } |

| 129 | // Prefix dec |

| 130 | Self &operator--() { |

| 131 | if (_node) |

| 132 | _node = _node->_next; |

| 133 | return *this; |

| 134 | } |

| 135 | // Postfix dec |

| 136 | Self operator--(int) { |

| 137 | Self tmp(_node); |

| 138 | --(*this); |

| 139 | return tmp; |

| 140 | } |

| 141 | ValueRef operator*() const { |

| 142 | assert(_node); |

| 143 | return static_cast<NodePtr>(_node)->_data; |

| 144 | } |

| 145 | ValuePtr operator->() const { |

| 146 | return &(operator*()); |

| 147 | } |

| 148 | |

| 149 | bool operator==(const Self &x) const { |

| 150 | return _node == x._node; |

| 151 | } |

| 152 | |

| 153 | bool operator!=(const Self &x) const { |

| 154 | return _node != x._node; |

| 155 | } |

| 156 | }; |

| 157 | |

| 158 | template<typename T> |