]> git.saurik.com Git - wxWidgets.git/commitdiff
iterator methods fixes (patch 1164808)
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 17 Mar 2005 23:19:13 +0000 (23:19 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 17 Mar 2005 23:19:13 +0000 (23:19 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32876 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/arrstr.h
include/wx/dynarray.h
include/wx/list.h
src/common/imagpcx.cpp
src/common/imagxpm.cpp
src/common/xpmdecod.cpp
src/generic/grid.cpp
src/gtk/window.cpp
src/gtk1/window.cpp

index cd8e84c08db5166d2f549d0ec21d730bbe24c6ea..36091d589a46b3e15c9f8b0b297e59245947da80 100644 (file)
@@ -227,13 +227,13 @@ public:
     reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { }
     reference operator*() const { return *m_ptr; }
     pointer operator->() const { return m_ptr; }
-    itor operator++() { --m_ptr; return *this; }
-    itor operator++(int)
+    itor& operator++() { --m_ptr; return *this; }
+    const itor operator++(int)
       { reverse_iterator tmp = *this; --m_ptr; return tmp; }
-    itor operator--() { ++m_ptr; return *this; }
-    itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }
-    bool operator ==(const itor& it) { return m_ptr == it.m_ptr; }
-    bool operator !=(const itor& it) { return m_ptr != it.m_ptr; }
+    itor& operator--() { ++m_ptr; return *this; }
+    const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }
+    bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }
+    bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }
   };
 
   class const_reverse_iterator
@@ -254,13 +254,13 @@ public:
     const_reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { }
     reference operator*() const { return *m_ptr; }
     pointer operator->() const { return m_ptr; }
-    itor operator++() { --m_ptr; return *this; }
-    itor operator++(int)
+    itor& operator++() { --m_ptr; return *this; }
+    const itor operator++(int)
       { itor tmp = *this; --m_ptr; return tmp; }
-    itor operator--() { ++m_ptr; return *this; }
-    itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }
-    bool operator ==(const itor& it) { return m_ptr == it.m_ptr; }
-    bool operator !=(const itor& it) { return m_ptr != it.m_ptr; }
+    itor& operator--() { ++m_ptr; return *this; }
+    const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }
+    bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }
+    bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }
   };
 
   wxArrayString(const_iterator first, const_iterator last)
index 0f1751ade0be029db1b67029ea75b8ed2d09db9d..2a0aabda647ace0e6bb488a4db60dce8a0e15dfb 100644 (file)
@@ -400,11 +400,11 @@ public:                                                               \
     reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { }            \
     reference operator*() const { return *m_ptr; }                    \
     ptrop                                                             \
-    itor operator++() { --m_ptr; return *this; }                      \
-    itor operator++(int)                                              \
+    itor& operator++() { --m_ptr; return *this; }                     \
+    const itor operator++(int)                                        \
       { reverse_iterator tmp = *this; --m_ptr; return tmp; }          \
-    itor operator--() { ++m_ptr; return *this; }                      \
-    itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }   \
+    itor& operator--() { ++m_ptr; return *this; }                     \
+    const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }\
     bool operator ==(const itor& it) { return m_ptr == it.m_ptr; }    \
     bool operator !=(const itor& it) { return m_ptr != it.m_ptr; }    \
   };                                                                  \
@@ -433,11 +433,11 @@ public:                                                               \
     const_reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { }\
     reference operator*() const { return *m_ptr; }                    \
     ptrop                                                             \
-    itor operator++() { --m_ptr; return *this; }                      \
-    itor operator++(int)                                              \
+    itor& operator++() { --m_ptr; return *this; }                     \
+    const itor operator++(int)                                        \
       { itor tmp = *this; --m_ptr; return tmp; }                      \
-    itor operator--() { ++m_ptr; return *this; }                      \
-    itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }   \
+    itor& operator--() { ++m_ptr; return *this; }                     \
+    const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }\
     bool operator ==(const itor& it) { return m_ptr == it.m_ptr; }    \
     bool operator !=(const itor& it) { return m_ptr != it.m_ptr; }    \
   };                                                                  \
index cb7023d3b7678dedb56243a12c03f3f7c91b3bbb..02805b9d03d8e80ed5c67e2c219b732778d61673 100644 (file)
@@ -170,9 +170,9 @@ private:
             compatibility_iterator* operator->() { return this; }             \
             const compatibility_iterator* operator->() const { return this; } \
                                                                               \
-            bool operator==(const compatibility_iterator& i)                  \
+            bool operator==(const compatibility_iterator& i) const            \
                 { return (m_list == i.m_list) && (m_iter == i.m_iter); }      \
-            bool operator!=(const compatibility_iterator& i)                  \
+            bool operator!=(const compatibility_iterator& i) const            \
                 { return !( operator==( i ) ); }                              \
             operator bool() const                                             \
                 { return m_list ? m_iter != m_list->end() : false; }          \
@@ -329,7 +329,6 @@ extern WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s);
 #endif
 
 class WXDLLEXPORT wxObjectListNode;
-typedef wxObjectListNode wxNode;
 
 // undef it to get rid of old, deprecated functions
 #define wxLIST_COMPATIBILITY
@@ -672,6 +671,7 @@ private:
         void SetData(T *data)                                               \
             { wxNodeBase::SetData(data); }                                  \
                                                                             \
+    protected:                                                              \
         virtual void DeleteData();                                          \
                                                                             \
         DECLARE_NO_COPY_CLASS(nodetype)                                     \
@@ -786,14 +786,14 @@ private:
                 { return *(pointer_type)m_node->GetDataPtr(); }             \
             ptrop                                                           \
             itor& operator++() { m_node = m_node->GetNext(); return *this; }\
-            itor operator++(int)                                            \
+            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;                                               \
             }                                                               \
-            itor operator--(int)                                            \
+            const itor operator--(int)                                      \
             {                                                               \
                 itor tmp = *this;                                           \
                 m_node = m_node ? m_node->GetPrevious() : m_init;           \
@@ -829,14 +829,14 @@ private:
                 { return *(pointer_type)m_node->GetDataPtr(); }             \
             ptrop                                                           \
             itor& operator++() { m_node = m_node->GetNext(); return *this; }\
-            itor operator++(int)                                            \
+            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;                                               \
             }                                                               \
-            itor operator--(int)                                            \
+            const itor operator--(int)                                      \
             {                                                               \
                 itor tmp = *this;                                           \
                 m_node = m_node ? m_node->GetPrevious() : m_init;           \
@@ -871,11 +871,11 @@ private:
             ptrop                                                           \
             itor& operator++()                                              \
                 { m_node = m_node->GetPrevious(); return *this; }           \
-            itor operator++(int)                                            \
+            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; } \
-            itor operator--(int)                                            \
+            const itor operator--(int)                                      \
             {                                                               \
                 itor tmp = *this;                                           \
                 m_node = m_node ? m_node->GetNext() : m_init;               \
@@ -912,11 +912,11 @@ private:
             ptrop                                                           \
             itor& operator++()                                              \
                 { m_node = m_node->GetPrevious(); return *this; }           \
-            itor operator++(int)                                            \
+            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;}\
-            itor operator--(int)                                            \
+            const itor operator--(int)                                      \
             {                                                               \
                 itor tmp = *this;                                           \
                 m_node = m_node ? m_node->GetNext() : m_init;               \
@@ -930,7 +930,7 @@ private:
                                                                             \
         wxEXPLICIT name(size_type n, const_reference v = value_type())      \
             { assign(n, v); }                                               \
-        name(const_iterator first, const_iterator last)                     \
+        name(const const_iterator& first, const const_iterator& last)       \
             { assign(first, last); }                                        \
         iterator begin() { return iterator(GetFirst(), GetLast()); }        \
         const_iterator begin() const                                        \
@@ -956,15 +956,15 @@ private:
         bool empty() const { return IsEmpty(); }                            \
         reference front() { return *begin(); }                              \
         const_reference front() const { return *begin(); }                  \
-        reference back() { return *--end(); }                               \
-        const_reference back() const { return *--end(); }                   \
+        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(), (const_base_reference)v); }                \
         void pop_front() { DeleteNode(GetFirst()); }                        \
         void push_back(const_reference v = value_type())                    \
             { Append((const_base_reference)v); }                            \
         void pop_back() { DeleteNode(GetLast()); }                          \
-        void assign(const_iterator first, const_iterator last)              \
+        void assign(const_iterator first, const const_iterator& last)       \
         {                                                                   \
             clear();                                                        \
             for(; first != last; ++first)                                   \
@@ -976,38 +976,38 @@ private:
             for(size_type i = 0; i < n; ++i)                                \
                 Append((const_base_reference)v);                            \
         }                                                                   \
-        iterator insert(iterator it, const_reference v = value_type())      \
+        iterator insert(const iterator& it, const_reference v = value_type())\
         {                                                                   \
             Insert(it.m_node, (const_base_reference)v);                     \
             return iterator(it.m_node->GetPrevious(), GetLast());           \
         }                                                                   \
-        void insert(iterator it, size_type n, const_reference v = value_type())\
+        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, (const_base_reference)v);                 \
         }                                                                   \
-        void insert(iterator it, const_iterator first, const_iterator last) \
+        void insert(const iterator& it, const_iterator first, const const_iterator& last)\
         {                                                                   \
             for(; first != last; ++first)                                   \
                 Insert(it.m_node, (const_base_reference)*first);            \
         }                                                                   \
-        iterator erase(iterator it)                                         \
+        iterator erase(const iterator& it)                                  \
         {                                                                   \
             iterator next = iterator(it.m_node->GetNext(), GetLast());      \
             DeleteNode(it.m_node); return next;                             \
         }                                                                   \
-        iterator erase(iterator first, iterator last)                       \
+        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(iterator it, name& l, iterator first, iterator last)    \
+        void splice(const iterator& it, name& l, const iterator& first, const iterator& last)\
             { insert(it, first, last); l.erase(first, last); }              \
-        void splice(iterator it, name& l)                                   \
+        void splice(const iterator& it, name& l)                            \
             { splice(it, l, l.begin(), l.end() ); }                         \
-        void splice(iterator it, name& l, iterator first)                   \
+        void splice(const iterator& it, name& l, const iterator& first)     \
         {                                                                   \
             iterator tmp = first; ++tmp;                                    \
             if(it == first || it == tmp) return;                            \
index 03364b381e99bccf447ee41f7eadc01bc8bd0ec3..00ebb750a6a78127b2418a4be0e2870c39427ed4 100644 (file)
@@ -418,7 +418,7 @@ int SavePCX(wxImage *image, wxOutputStream& stream)
         unsigned long index;
 
         for (wxImageHistogram::iterator entry = histogram.begin();
-             entry != histogram.end(); entry++ )
+             entry != histogram.end(); ++entry )
         {
             key = entry->first;
             index = entry->second.index;
index 7da5a26011e57b88f24156c35808313d489d6928..5e8db820c959131a90a6d5e2b95b604b6b88c831 100644 (file)
@@ -180,7 +180,7 @@ bool wxXPMHandler::SaveFile(wxImage * image,
 
     // 2b. generate colour table:
     for (wxImageHistogram::iterator entry = histogram.begin();
-         entry != histogram.end(); entry++ )
+         entry != histogram.end(); ++entry )
     {
         unsigned long index = entry->second.index;
         symbols[index] = symbols_data + index * (chars_per_pixel+1);
index ed784fb578cc9b061c69e8b9fcb3cc5aa6721a7f..e30022e8c7466dfda81ab1cd8091809a48d7d5ad 100644 (file)
@@ -742,7 +742,7 @@ wxImage wxXPMDecoder::ReadData(const char **xpm_data)
      */
     if (hasMask)
     {
-        for (it = clr_tbl.begin(); it != clr_tbl.end(); it++)
+        for (it = clr_tbl.begin(); it != clr_tbl.end(); ++it)
         {
             if (it->second.R == 255 && it->second.G == 0 &&
                 it->second.B == 255 &&
index 47190211460c7e982582c7540dd204315a7c9a30..098126e2b72bf9e08fe5ab128b2aed2cb39a340b 100644 (file)
@@ -4713,7 +4713,7 @@ wxArrayInt wxGrid::CalcRowLabelsExposed( const wxRegion& reg )
             rowlabels.Add( row );
         }
 
-        iter++ ;
+        ++iter;
     }
 
     return rowlabels;
@@ -4764,7 +4764,7 @@ wxArrayInt wxGrid::CalcColLabelsExposed( const wxRegion& reg )
             colLabels.Add( col );
         }
 
-        iter++ ;
+        ++iter;
     }
     return colLabels;
 }
@@ -4824,7 +4824,7 @@ wxGridCellCoordsArray wxGrid::CalcCellsExposed( const wxRegion& reg )
             }
         }
 
-        iter++;
+        ++iter;
     }
 
     return cellsExposed;
index b02e6a4f86f4b4aeb7f67377e27e22fea215c3f5..b4f55985b8139a96122d1c3d0f83eaedebc76e2f 100644 (file)
@@ -4021,7 +4021,7 @@ void wxWindowGTK::GtkSendPaintEvents()
                             (char *)"base",
                             0, 0, -1, -1 );
 
-                upd ++;
+                ++upd;
             }
         }
     }
index b02e6a4f86f4b4aeb7f67377e27e22fea215c3f5..b4f55985b8139a96122d1c3d0f83eaedebc76e2f 100644 (file)
@@ -4021,7 +4021,7 @@ void wxWindowGTK::GtkSendPaintEvents()
                             (char *)"base",
                             0, 0, -1, -1 );
 
-                upd ++;
+                ++upd;
             }
         }
     }