\helpref{WX\_CLEAR\_ARRAY}{wxcleararray}\\
\helpref{Empty}{wxarrayempty}\\
\helpref{Clear}{wxarrayclear}\\
+\helpref{RemoveAt}{wxarrayremoveat}\\
\helpref{Remove}{wxarrayremove}
\membersection{Searching and sorting}
\func{T *}{Detach}{\param{size\_t }{index}}
Removes the element from the array, but, unlike,
-
\helpref{Remove()}{wxarrayremove} doesn't delete it. The function returns the
pointer to the removed element.
\membersection{wxArray::Remove}\label{wxarrayremove}
-\func{\void}{Remove}{\param{size\_t }{index}}
-
\func{\void}{Remove}{\param{T }{item}}
-Removes the element from the array either by index or by value. When an element
-is removed from wxObjArray it is deleted by the array - use
+Removes the element from the array either by value: the first item of the
+array equal to {\it item} is removed, an assert failure will result from an
+attempt to remove an item which doesn't exist in the array.
+
+When an element is removed from wxObjArray it is deleted by the array - use
\helpref{Detach()}{wxobjarraydetach} if you don't want this to happen. On the
other hand, when an object is removed from a wxArray nothing happens - you
should delete the it manually if required:
See also \helpref{WX\_CLEAR\_ARRAY}{wxcleararray} macro which deletes all
elements of a wxArray (supposed to contain pointers).
+\membersection{wxArray::RemoveAt}\label{wxarrayremoveat}
+
+\func{\void}{RemoveAt}{\param{size\_t }{index}}
+
+Removes the element from the array either by index. When an element
+is removed from wxObjArray it is deleted by the array - use
+\helpref{Detach()}{wxobjarraydetach} if you don't want this to happen. On the
+other hand, when an object is removed from a wxArray nothing happens - you
+should delete the it manually if required:
+
+\begin{verbatim}
+T *item = array[n];
+delete item;
+array.RemoveAt(n)
+\end{verbatim}
+
+See also \helpref{WX\_CLEAR\_ARRAY}{wxcleararray} macro which deletes all
+elements of a wxArray (supposed to contain pointers).
+
\membersection{wxArray::Shrink}\label{wxarrayshrink}
\func{void}{Shrink}{\void}
*****************************************************************************/
// needed to resolve the conflict between global T and macro parameter T
-#define _WX_ERROR_REMOVE2(x) wxT("bad index in " #x "::Remove()")
+#define _WX_ERROR_REMOVE2(x) wxT("bad index in " #x "::RemoveAt()")
// macro implements remaining (not inline) methods of template list
// (it's private to this file)
wxBaseArray::Clear(); \
} \
\
-void name::Remove(size_t uiIndex) \
+void name::RemoveAt(size_t uiIndex) \
{ \
wxCHECK_RET( uiIndex < Count(), _WX_ERROR_REMOVE2(name) ); \
\
delete (T*)wxBaseArray::Item(uiIndex); \
\
- wxBaseArray::Remove(uiIndex); \
+ wxBaseArray::RemoveAt(uiIndex); \
} \
\
void name::Add(const T& item) \
/// 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
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, \
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, \
T* Detach(size_t uiIndex) \
{ T* p = (T*)wxBaseArray::Item(uiIndex); \
wxBaseArray::Remove(uiIndex); return p; } \
- void Remove(size_t uiIndex); \
+ void Remove(size_t uiIndex) { RemoveAt(uiIndex); } \
+ void RemoveAt(size_t uiIndex); \
\
void Sort(CMPFUNC##T fCmp) { wxBaseArray::Sort((CMPFUNC)fCmp); } \
\
}
// removes item from array (by index)
-void wxBaseArray::Remove(size_t nIndex)
+void wxBaseArray::RemoveAt(size_t nIndex)
{
- wxCHECK_RET( nIndex <= m_nCount, wxT("bad index in wxArray::Remove") );
+ wxCHECK_RET( nIndex <= m_nCount, wxT("bad index in wxArray::RemoveAt") );
memmove(&m_pItems[nIndex], &m_pItems[nIndex + 1],
(m_nCount - nIndex - 1)*sizeof(long));