-
- /* STL interface */
- public:
- typedef size_t size_type;
- typedef int difference_type;
- typedef T* value_type;
- typedef value_type& reference;
- typedef const value_type& const_reference;
-
- class iterator
- {
- public:
- typedef nodetype Node;
- typedef iterator itor;
- typedef T* value_type;
- typedef value_type* ptr_type;
- typedef value_type& reference;
-
- Node* m_node;
- Node* m_init;
- public:
- typedef reference reference_type;
- typedef ptr_type pointer_type;
-
- iterator(Node* node, Node* init) : m_node(node), m_init(init) {}
- iterator() : m_node(NULL), m_init(NULL) { }
- reference_type operator*() const
- { return *m_node->GetDataPtr(); }
- // ptrop
- itor& operator++() { m_node = m_node->GetNext(); return *this; }
- const itor operator++(int)
- { itor tmp = *this; m_node = m_node->GetNext(); return tmp; }
- itor& operator--()
- {
- m_node = m_node ? m_node->GetPrevious() : m_init;
- return *this;
- }
- const itor operator--(int)
- {
- itor tmp = *this;
- m_node = m_node ? m_node->GetPrevious() : m_init;
- return tmp;
- }
- bool operator!=(const itor& it) const
- { return it.m_node != m_node; }
- bool operator==(const itor& it) const
- { return it.m_node == m_node; }
- };
- class const_iterator
- {
- public:
- typedef nodetype Node;
- typedef T* value_type;
- typedef const value_type& const_reference;
- typedef const_iterator itor;
- typedef value_type* ptr_type;
-
- Node* m_node;
- Node* m_init;
- public:
- typedef const_reference reference_type;
- typedef const ptr_type pointer_type;
-
- const_iterator(Node* node, Node* init)
- : m_node(node), m_init(init) { }
- const_iterator() : m_node(NULL), m_init(NULL) { }
- const_iterator(const iterator& it)
- : m_node(it.m_node), m_init(it.m_init) { }
- reference_type operator*() const
- { return *m_node->GetDataPtr(); }
- // ptrop
- itor& operator++() { m_node = m_node->GetNext(); return *this; }
- const itor operator++(int)
- { itor tmp = *this; m_node = m_node->GetNext(); return tmp; }
- itor& operator--()
- {
- m_node = m_node ? m_node->GetPrevious() : m_init;
- return *this;
- }
- const itor operator--(int)
- {
- itor tmp = *this;
- m_node = m_node ? m_node->GetPrevious() : m_init;
- return tmp;
- }
- bool operator!=(const itor& it) const
- { return it.m_node != m_node; }
- bool operator==(const itor& it) const
- { return it.m_node == m_node; }
- };
- class reverse_iterator
- {
- public:
- typedef nodetype Node;
- typedef T* value_type;
- typedef reverse_iterator itor;
- typedef value_type* ptr_type;
- typedef value_type& reference;
-
- Node* m_node;
- Node* m_init;
- public:
- typedef reference reference_type;
- typedef ptr_type pointer_type;
-
- reverse_iterator(Node* node, Node* init)
- : m_node(node), m_init(init) { }
- reverse_iterator() : m_node(NULL), m_init(NULL) { }
- reference_type operator*() const
- { return *m_node->GetDataPtr(); }
- // ptrop
- itor& operator++()
- { m_node = m_node->GetPrevious(); return *this; }
- const itor operator++(int)
- { itor tmp = *this; m_node = m_node->GetPrevious(); return tmp; }
- itor& operator--()
- { m_node = m_node ? m_node->GetNext() : m_init; return *this; }
- const itor operator--(int)
- {
- itor tmp = *this;
- m_node = m_node ? m_node->GetNext() : m_init;
- return tmp;
- }
- bool operator!=(const itor& it) const
- { return it.m_node != m_node; }
- bool operator==(const itor& it) const
- { return it.m_node == m_node; }
- };
- class const_reverse_iterator
- {
- public:
- typedef nodetype Node;
- typedef T* value_type;
- typedef const_reverse_iterator itor;
- typedef value_type* ptr_type;
- typedef const value_type& const_reference;
-
- Node* m_node;
- Node* m_init;
- public:
- typedef const_reference reference_type;
- typedef const ptr_type pointer_type;
-
- const_reverse_iterator(Node* node, Node* init)
- : m_node(node), m_init(init) { }
- const_reverse_iterator() : m_node(NULL), m_init(NULL) { }
- const_reverse_iterator(const reverse_iterator& it)
- : m_node(it.m_node), m_init(it.m_init) { }
- reference_type operator*() const
- { return *m_node->GetDataPtr(); }
- // ptrop
- itor& operator++()
- { m_node = m_node->GetPrevious(); return *this; }
- const itor operator++(int)
- { itor tmp = *this; m_node = m_node->GetPrevious(); return tmp; }
- itor& operator--()
- { m_node = m_node ? m_node->GetNext() : m_init; return *this;}
- const itor operator--(int)
- {
- itor tmp = *this;
- m_node = m_node ? m_node->GetNext() : m_init;
- return tmp;
- }
- bool operator!=(const itor& it) const
- { return it.m_node != m_node; }
- bool operator==(const itor& it) const
- { return it.m_node == m_node; }
- };
-
- wxEXPLICIT wxDList(size_type n, const_reference v = value_type())
- { assign(n, v); }
- wxDList(const const_iterator& first, const const_iterator& last)
- { assign(first, last); }
- iterator begin() { return iterator(GetFirst(), GetLast()); }
- const_iterator begin() const
- { return const_iterator(GetFirst(), GetLast()); }
- iterator end() { return iterator(NULL, GetLast()); }
- const_iterator end() const { return const_iterator(NULL, GetLast()); }
- reverse_iterator rbegin()
- { return reverse_iterator(GetLast(), GetFirst()); }
- const_reverse_iterator rbegin() const
- { return const_reverse_iterator(GetLast(), GetFirst()); }
- reverse_iterator rend() { return reverse_iterator(NULL, GetFirst()); }
- const_reverse_iterator rend() const
- { return const_reverse_iterator(NULL, GetFirst()); }
- void resize(size_type n, value_type v = value_type())
- {
- while (n < size())
- pop_back();
- while (n > size())
- push_back(v);
- }
- size_type size() const { return GetCount(); }
- size_type max_size() const { return INT_MAX; }
- bool empty() const { return IsEmpty(); }
- reference front() { return *begin(); }
- const_reference front() const { return *begin(); }
- reference back() { iterator tmp = end(); return *--tmp; }
- const_reference back() const { const_iterator tmp = end(); return *--tmp; }
- void push_front(const_reference v = value_type())
- { Insert(GetFirst(), v); }
- void pop_front() { DeleteNode(GetFirst()); }
- void push_back(const_reference v = value_type())
- { Append( v ); }
- void pop_back() { DeleteNode(GetLast()); }
- void assign(const_iterator first, const const_iterator& last)
- {
- clear();
- for(; first != last; ++first)
- Append(*first);
- }
- void assign(size_type n, const_reference v = value_type())
- {
- clear();
- for(size_type i = 0; i < n; ++i)
- Append(v);
- }
- iterator insert(const iterator& it, const_reference v = value_type())
- {
- Insert(it.m_node,v);
- iterator itprev(it);
- return itprev--;
- }
- void insert(const iterator& it, size_type n, const_reference v = value_type())
- {
- for(size_type i = 0; i < n; ++i)
- Insert(it.m_node, v);
- }
- void insert(const iterator& it, const_iterator first, const const_iterator& last)
- {
- for(; first != last; ++first)
- Insert(it.m_node, *first);
- }
- iterator erase(const iterator& it)
- {
- iterator next = iterator(it.m_node->GetNext(), GetLast());
- DeleteNode(it.m_node); return next;
- }
- iterator erase(const iterator& first, const iterator& last)
- {
- iterator next = last; ++next;
- DeleteNodes(first.m_node, last.m_node);
- return next;
- }
- void clear() { Clear(); }
- void splice(const iterator& it, wxDList<T>& l, const iterator& first, const iterator& last)
- { insert(it, first, last); l.erase(first, last); }
- void splice(const iterator& it, wxDList<T>& l)
- { splice(it, l, l.begin(), l.end() ); }
- void splice(const iterator& it, wxDList<T>& l, const iterator& first)
- {
- iterator tmp = first; ++tmp;
- if(it == first || it == tmp) return;
- insert(it, *first);
- l.erase(first);
- }
- void remove(const_reference v)
- { DeleteObject(v); }
- void reverse()
- { Reverse(); }
- /* void swap(list<T>& l)
- {
- { size_t t = m_count; m_count = l.m_count; l.m_count = t; }
- { bool t = m_destroy; m_destroy = l.m_destroy; l.m_destroy = t; }
- { wxNodeBase* t = m_nodeFirst; m_nodeFirst = l.m_nodeFirst; l.m_nodeFirst = t; }
- { wxNodeBase* t = m_nodeLast; m_nodeLast = l.m_nodeLast; l.m_nodeLast = t; }
- { wxKeyType t = m_keyType; m_keyType = l.m_keyType; l.m_keyType = t; }
- } */
+
+ /* STL interface */
+public:
+ typedef size_t size_type;
+ typedef int difference_type;
+ typedef T* value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+
+ class iterator
+ {
+ public:
+ typedef nodetype Node;
+ typedef iterator itor;
+ typedef T* value_type;
+ typedef value_type* ptr_type;
+ typedef value_type& reference;
+
+ Node* m_node;
+ Node* m_init;
+ public:
+ typedef reference reference_type;
+ typedef ptr_type pointer_type;
+
+ iterator(Node* node, Node* init) : m_node(node), m_init(init) {}
+ iterator() : m_node(NULL), m_init(NULL) { }
+ reference_type operator*() const
+ { return *m_node->GetDataPtr(); }
+ // ptrop
+ itor& operator++() { m_node = m_node->GetNext(); return *this; }
+ const itor operator++(int)
+ { itor tmp = *this; m_node = m_node->GetNext(); return tmp; }
+ itor& operator--()
+ {
+ m_node = m_node ? m_node->GetPrevious() : m_init;
+ return *this;
+ }
+ const itor operator--(int)
+ {
+ itor tmp = *this;
+ m_node = m_node ? m_node->GetPrevious() : m_init;
+ return tmp;
+ }
+ bool operator!=(const itor& it) const
+ { return it.m_node != m_node; }
+ bool operator==(const itor& it) const
+ { return it.m_node == m_node; }
+ };
+ class const_iterator
+ {
+ public:
+ typedef nodetype Node;
+ typedef T* value_type;
+ typedef const value_type& const_reference;
+ typedef const_iterator itor;
+ typedef value_type* ptr_type;
+
+ Node* m_node;
+ Node* m_init;
+ public:
+ typedef const_reference reference_type;
+ typedef const ptr_type pointer_type;
+
+ const_iterator(Node* node, Node* init)
+ : m_node(node), m_init(init) { }
+ const_iterator() : m_node(NULL), m_init(NULL) { }
+ const_iterator(const iterator& it)
+ : m_node(it.m_node), m_init(it.m_init) { }
+ reference_type operator*() const
+ { return *m_node->GetDataPtr(); }
+ // ptrop
+ itor& operator++() { m_node = m_node->GetNext(); return *this; }
+ const itor operator++(int)
+ { itor tmp = *this; m_node = m_node->GetNext(); return tmp; }
+ itor& operator--()
+ {
+ m_node = m_node ? m_node->GetPrevious() : m_init;
+ return *this;
+ }
+ const itor operator--(int)
+ {
+ itor tmp = *this;
+ m_node = m_node ? m_node->GetPrevious() : m_init;
+ return tmp;
+ }
+ bool operator!=(const itor& it) const
+ { return it.m_node != m_node; }
+ bool operator==(const itor& it) const
+ { return it.m_node == m_node; }
+ };
+
+ class reverse_iterator
+ {
+ public:
+ typedef nodetype Node;
+ typedef T* value_type;
+ typedef reverse_iterator itor;
+ typedef value_type* ptr_type;
+ typedef value_type& reference;
+
+ Node* m_node;
+ Node* m_init;
+ public:
+ typedef reference reference_type;
+ typedef ptr_type pointer_type;
+
+ reverse_iterator(Node* node, Node* init)
+ : m_node(node), m_init(init) { }
+ reverse_iterator() : m_node(NULL), m_init(NULL) { }
+ reference_type operator*() const
+ { return *m_node->GetDataPtr(); }
+ // ptrop
+ itor& operator++()
+ { m_node = m_node->GetPrevious(); return *this; }
+ const itor operator++(int)
+ { itor tmp = *this; m_node = m_node->GetPrevious(); return tmp; }
+ itor& operator--()
+ { m_node = m_node ? m_node->GetNext() : m_init; return *this; }
+ const itor operator--(int)
+ {
+ itor tmp = *this;
+ m_node = m_node ? m_node->GetNext() : m_init;
+ return tmp;
+ }
+ bool operator!=(const itor& it) const
+ { return it.m_node != m_node; }
+ bool operator==(const itor& it) const
+ { return it.m_node == m_node; }
+ };
+
+ class const_reverse_iterator
+ {
+ public:
+ typedef nodetype Node;
+ typedef T* value_type;
+ typedef const_reverse_iterator itor;
+ typedef value_type* ptr_type;
+ typedef const value_type& const_reference;
+
+ Node* m_node;
+ Node* m_init;
+ public:
+ typedef const_reference reference_type;
+ typedef const ptr_type pointer_type;
+
+ const_reverse_iterator(Node* node, Node* init)
+ : m_node(node), m_init(init) { }
+ const_reverse_iterator() : m_node(NULL), m_init(NULL) { }
+ const_reverse_iterator(const reverse_iterator& it)
+ : m_node(it.m_node), m_init(it.m_init) { }
+ reference_type operator*() const
+ { return *m_node->GetDataPtr(); }
+ // ptrop
+ itor& operator++()
+ { m_node = m_node->GetPrevious(); return *this; }
+ const itor operator++(int)
+ { itor tmp = *this; m_node = m_node->GetPrevious(); return tmp; }
+ itor& operator--()
+ { m_node = m_node ? m_node->GetNext() : m_init; return *this;}
+ const itor operator--(int)
+ {
+ itor tmp = *this;
+ m_node = m_node ? m_node->GetNext() : m_init;
+ return tmp;
+ }
+ bool operator!=(const itor& it) const
+ { return it.m_node != m_node; }
+ bool operator==(const itor& it) const
+ { return it.m_node == m_node; }
+ };
+
+ wxEXPLICIT wxDList(size_type n, const_reference v = value_type())
+ { assign(n, v); }
+ wxDList(const const_iterator& first, const const_iterator& last)
+ { assign(first, last); }
+ iterator begin() { return iterator(GetFirst(), GetLast()); }
+ const_iterator begin() const
+ { return const_iterator(GetFirst(), GetLast()); }
+ iterator end() { return iterator(NULL, GetLast()); }
+ const_iterator end() const { return const_iterator(NULL, GetLast()); }
+ reverse_iterator rbegin()
+ { return reverse_iterator(GetLast(), GetFirst()); }
+ const_reverse_iterator rbegin() const
+ { return const_reverse_iterator(GetLast(), GetFirst()); }
+ reverse_iterator rend() { return reverse_iterator(NULL, GetFirst()); }
+ const_reverse_iterator rend() const
+ { return const_reverse_iterator(NULL, GetFirst()); }
+ void resize(size_type n, value_type v = value_type())
+ {
+ while (n < size())
+ pop_back();
+ while (n > size())
+ push_back(v);
+ }
+ size_type size() const { return GetCount(); }
+ size_type max_size() const { return INT_MAX; }
+ bool empty() const { return IsEmpty(); }
+ reference front() { return *begin(); }
+ const_reference front() const { return *begin(); }
+ reference back() { iterator tmp = end(); return *--tmp; }
+ const_reference back() const { const_iterator tmp = end(); return *--tmp; }
+ void push_front(const_reference v = value_type())
+ { Insert(GetFirst(), v); }
+ void pop_front() { DeleteNode(GetFirst()); }
+ void push_back(const_reference v = value_type())
+ { Append( v ); }
+ void pop_back() { DeleteNode(GetLast()); }
+ void assign(const_iterator first, const const_iterator& last)
+ {
+ clear();
+ for(; first != last; ++first)
+ Append(*first);
+ }
+ void assign(size_type n, const_reference v = value_type())
+ {
+ clear();
+ for(size_type i = 0; i < n; ++i)
+ Append(v);
+ }
+ iterator insert(const iterator& it, const_reference v)
+ {
+ if (it == end())
+ Append( v );
+ else
+ Insert(it.m_node,v);
+ iterator itprev(it);
+ return itprev--;
+ }
+ void insert(const iterator& it, size_type n, const_reference v)
+ {
+ for(size_type i = 0; i < n; ++i)
+ Insert(it.m_node, v);
+ }
+ void insert(const iterator& it, const_iterator first, const const_iterator& last)
+ {
+ for(; first != last; ++first)
+ Insert(it.m_node, *first);
+ }
+ iterator erase(const iterator& it)
+ {
+ iterator next = iterator(it.m_node->GetNext(), GetLast());
+ DeleteNode(it.m_node); return next;
+ }
+ iterator erase(const iterator& first, const iterator& last)
+ {
+ iterator next = last; ++next;
+ DeleteNodes(first.m_node, last.m_node);
+ return next;
+ }
+ void clear() { Clear(); }
+ void splice(const iterator& it, wxDList<T>& l, const iterator& first, const iterator& last)
+ { insert(it, first, last); l.erase(first, last); }
+ void splice(const iterator& it, wxDList<T>& l)
+ { splice(it, l, l.begin(), l.end() ); }
+ void splice(const iterator& it, wxDList<T>& l, const iterator& first)
+ {
+ iterator tmp = first; ++tmp;
+ if(it == first || it == tmp) return;
+ insert(it, *first);
+ l.erase(first);
+ }
+ void remove(const_reference v)
+ { DeleteObject(v); }
+ void reverse()
+ { Reverse(); }
+ /* void swap(list<T>& l)
+ {
+ { size_t t = m_count; m_count = l.m_count; l.m_count = t; }
+ { bool t = m_destroy; m_destroy = l.m_destroy; l.m_destroy = t; }
+ { wxNodeBase* t = m_nodeFirst; m_nodeFirst = l.m_nodeFirst; l.m_nodeFirst = t; }
+ { wxNodeBase* t = m_nodeLast; m_nodeLast = l.m_nodeLast; l.m_nodeLast = t; }
+ { wxKeyType t = m_keyType; m_keyType = l.m_keyType; l.m_keyType = t; }
+ } */