wxSortedArray::Add must return the index of the newly

inserted item.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21875 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-07-10 19:32:04 +00:00
parent fcd0c90f75
commit 6992d326eb
2 changed files with 9 additions and 8 deletions

View 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); } \

View 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