-template <typename T, typename Tag>
-class intrusive_list
-{
- public:
- class iterator : public std::iterator<std::bidirectional_iterator_tag, T*>
- {
- T* curr;
-
- public:
- iterator(T* i = NULL)
- : curr(i)
- {
- }
-
- iterator& operator++()
- {
- curr = curr->intrusive_list_node<T, Tag>::ptr_next;
- return *this;
- }
-
- iterator operator++(int)
- {
- iterator ret(*this);
- operator++();
- return ret;
- }
-
- void operator--()
- {
- curr = curr->intrusive_list_node<T, Tag>::ptr_prev;
- return *this;
- }
-
- iterator operator--(int)
- {
- iterator ret(*this);
- operator--();
- return ret;
- }
-
- bool operator==(const iterator& other) const { return (curr == other.curr); }
- bool operator!=(const iterator& other) const { return (curr != other.curr); }
- T* operator*() const { return curr; }
- };
-
- typedef iterator const_iterator;
-
- intrusive_list()
- : listhead(NULL)
- , listsize(0)
- {
- }
-
- bool empty() const
- {
- return (size() == 0);
- }
-
- size_t size() const
- {
- return listsize;
- }
-
- iterator begin() const
- {
- return iterator(listhead);
- }
-
- iterator end() const
- {
- return iterator();
- }