]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/dynarray.h
corrected comment
[wxWidgets.git] / include / wx / dynarray.h
index a3c4017ada52beba2b7d6caa86a49fa6394d8beb..702df0bad0f1fbdc9aa4ec56ea83559dba331d1c 100644 (file)
@@ -17,7 +17,6 @@
 #endif
 
 #include "wx/defs.h"
-#include "wx/debug.h"
 
 /** @name Dynamic arrays and object arrays (array which own their elements)
     @memo Arrays which grow on demand and do range checking (only in debug)
@@ -132,7 +131,7 @@ protected:
     /// remove first item matching this value
   void Remove(long lItem);
     /// remove item by index
-  void Remove(size_t uiIndex);
+  void RemoveAt(size_t uiIndex);
   //@}
 
   /// sort array elements using given compare function
@@ -198,12 +197,13 @@ public:                                                             \
   void Insert(T Item, size_t uiIndex)                               \
     { wxBaseArray::Insert((long)Item, uiIndex) ; }                  \
                                                                     \
-  void Remove(size_t uiIndex) { wxBaseArray::Remove(uiIndex); }     \
+  void Remove(size_t uiIndex) { RemoveAt(uiIndex); }                \
+  void RemoveAt(size_t uiIndex) { wxBaseArray::RemoveAt(uiIndex); } \
   void Remove(T Item)                                               \
     { int iIndex = Index(Item);                                     \
       wxCHECK2_MSG( iIndex != wxNOT_FOUND, return,                  \
          _WX_ERROR_REMOVE);                                         \
-      wxBaseArray::Remove((size_t)iIndex); }                        \
+      wxBaseArray::RemoveAt((size_t)iIndex); }                      \
                                                                     \
   void Sort(CMPFUNC##T fCmp) { wxBaseArray::Sort((CMPFUNC)fCmp); }  \
 }
@@ -260,12 +260,13 @@ public:                                                             \
   void Add(T Item)                                                  \
     { wxBaseArray::Add((long)Item, (CMPFUNC)m_fnCompare); }         \
                                                                     \
-  void Remove(size_t uiIndex) { wxBaseArray::Remove(uiIndex); }     \
+  void Remove(size_t uiIndex) { RemoveAt(uiIndex); }                \
+  void RemoveAt(size_t uiIndex) { wxBaseArray::RemoveAt(uiIndex); } \
   void Remove(T Item)                                               \
     { int iIndex = Index(Item);                                     \
       wxCHECK2_MSG( iIndex != wxNOT_FOUND, return,                  \
         _WX_ERROR_REMOVE );                                         \
-      wxBaseArray::Remove((size_t)iIndex); }                        \
+      wxBaseArray::RemoveAt((size_t)iIndex); }                      \
                                                                     \
 private:                                                            \
   SCMPFUNC##T m_fnCompare;                                          \
@@ -302,16 +303,19 @@ public:                                                             \
   void Insert(const T* pItem, size_t uiIndex)                       \
     { wxBaseArray::Insert((long)pItem, uiIndex); }                  \
                                                                     \
-  void Empty();                                                     \
+  void Empty() { DoEmpty(); wxBaseArray::Empty(); }                 \
+  void Clear() { DoEmpty(); wxBaseArray::Clear(); }                 \
                                                                     \
   T*   Detach(size_t uiIndex)                                       \
     { T* p = (T*)wxBaseArray::Item(uiIndex);                        \
-      wxBaseArray::Remove(uiIndex); return p; }                     \
-  void Remove(size_t uiIndex);                                      \
+      wxBaseArray::RemoveAt(uiIndex); return p; }                   \
+  void Remove(size_t uiIndex) { RemoveAt(uiIndex); }                \
+  void RemoveAt(size_t uiIndex);                                    \
                                                                     \
   void Sort(CMPFUNC##T fCmp) { wxBaseArray::Sort((CMPFUNC)fCmp); }  \
                                                                     \
 private:                                                            \
+  void DoEmpty();                                                   \
   void DoCopy(const name& src);                                     \
 }
 
@@ -445,6 +449,16 @@ WX_DEFINE_EXPORTED_ARRAY(void *, wxArrayPtrVoid);
 // convinience macros
 // -----------------------------------------------------------------------------
 
+// append all element of one array to another one
+#define WX_APPEND_ARRAY(array, other)                                         \
+    {                                                                         \
+        size_t count = other.Count();                                         \
+        for ( size_t n = 0; n < count; n++ )                                  \
+        {                                                                     \
+            array.Add(other[n]);                                              \
+        }                                                                     \
+    }
+
 // delete all array elements
 //
 // NB: the class declaration of the array elements must be visible from the