]> git.saurik.com Git - wxWidgets.git/commitdiff
wxSortedArray::Add must return the index of the newly
authorMattia Barbon <mbarbon@cpan.org>
Thu, 10 Jul 2003 19:32:04 +0000 (19:32 +0000)
committerMattia Barbon <mbarbon@cpan.org>
Thu, 10 Jul 2003 19:32:04 +0000 (19:32 +0000)
inserted item.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21875 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/dynarray.h
src/common/dynarray.cpp

index c1d42f59f358fb64b53dfda616c9b404cd150cbe..b022b49a9cb978df0052942871e91700f2353a02 100644 (file)
@@ -114,7 +114,7 @@ protected:                                                          \
   size_t IndexForInsert(T lItem, CMPFUNC fnCompare) const;          \
   void Add(T lItem, size_t nInsert = 1)                             \
     { insert(end(), nInsert, lItem); }                              \
-  void Add(T lItem, CMPFUNC fnCompare);                             \
+  size_t Add(T lItem, CMPFUNC fnCompare);                           \
   void Insert(T lItem, size_t uiIndex, size_t nInsert = 1)          \
     { insert(begin() + uiIndex, nInsert, lItem); }                  \
   void Remove(T lItem);                                             \
@@ -170,7 +170,7 @@ protected:                                                          \
   int Index(T lItem, CMPFUNC fnCompare) const;                      \
   size_t IndexForInsert(T lItem, CMPFUNC fnCompare) const;          \
   void Add(T lItem, size_t nInsert = 1);                            \
-  void Add(T lItem, CMPFUNC fnCompare);                             \
+  size_t Add(T lItem, CMPFUNC fnCompare);                           \
   void Insert(T lItem, size_t uiIndex, size_t nInsert = 1);         \
   void Remove(T lItem);                                             \
   void RemoveAt(size_t uiIndex, size_t nRemove = 1);                \
@@ -488,8 +488,8 @@ public:                                                               \
   void AddAt(T item, size_t index)                                    \
     { base::insert(begin() + index, item); }                          \
                                                                       \
-  void Add(T Item)                                                    \
-    { base::Add(Item, (CMPFUNC)m_fnCompare); }                        \
+  size_t Add(T Item)                                                  \
+    { return base::Add(Item, (CMPFUNC)m_fnCompare); }                 \
                                                                       \
   void RemoveAt(size_t uiIndex, size_t nRemove = 1)                   \
     { base::erase(begin() + uiIndex, begin() + uiIndex + nRemove); }  \
index 39db10d384bab1b0c0acab4c136212f113f8cde8..038947c6bade74dc367de3746e5b97e28450de0b 100644 (file)
@@ -78,11 +78,12 @@ int name::Index(T lItem, bool bFromEnd) const                               \
 }                                                                           \
                                                                             \
 /* add item assuming the array is sorted with fnCompare function */         \
-void name::Add(T lItem, CMPFUNC fnCompare)                                  \
+size_t name::Add(T lItem, CMPFUNC fnCompare)                                \
 {                                                                           \
-  Insert(lItem, IndexForInsert(lItem, fnCompare));                          \
-}                                                                           \
-                                                                            \
+  size_t idx = IndexForInsert(lItem, fnCompare);                            \
+  Insert(lItem, idx);                                                       \
+  return idx;                                                               \
+}
 
 #if wxUSE_STL