// Purpose: interface of wxArray<T>
// Author: wxWidgets team
// RCS-ID: $Id$
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
functions are inline, so they do not take @e any space at all.
wxWidgets has three different kinds of array. All of them derive from
- wxBaseArray class which works with untyped data and can not be used
+ wxBaseArray class which works with untyped data and cannot be used
directly. The standard macros WX_DEFINE_ARRAY(), WX_DEFINE_SORTED_ARRAY()
and WX_DEFINE_OBJARRAY() are used to define a new class deriving from it.
The classes declared will be called in this documentation wxArray,
however dumb, C++ compiler in the world.
Remember to include @<wx/arrimpl.cpp@> just before each
- WX_DEFINE_OBJARRAY() ocurrence in your code, even if you have several in
+ WX_DEFINE_OBJARRAY() occurrence in your code, even if you have several in
the same file.
Things are much simpler for wxArray and wxSortedArray however: it is enough
- WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_INT()
+ @section array_predef Predefined array types
+
+ wxWidgets defines the following dynamic array types:
+ - ::wxArrayShort
+ - ::wxArrayInt
+ - ::wxArrayDouble
+ - ::wxArrayLong
+ - ::wxArrayPtrVoid
+
+ To use them you don't need any macro; you just need to include @c dynarray.h.
+
+
@library{wxbase}
@category{containers}
@see @ref overview_container, wxList<T>, wxVector<T>
*/
+template <typename T>
class wxArray<T>
{
public:
@code
T *item = array[n];
+ array.Remove(item);
delete item;
- array.Remove(n);
@endcode
See also WX_CLEAR_ARRAY() macro which deletes all elements of a wxArray
(supposed to contain pointers).
+
+ Notice that for sorted arrays this method uses binary search to find
+ the item so it doesn't necessarily remove the first matching item, but
+ the first one found by the binary search.
+
+ @see RemoveAt()
*/
- Remove(T item);
+ void Remove(T item);
/**
Removes @a count elements starting at @a index from the array. When an
See also WX_CLEAR_ARRAY() macro which deletes all elements of a wxArray
(supposed to contain pointers).
*/
- RemoveAt(size_t index, size_t count = 1);
+ void RemoveAt(size_t index, size_t count = 1);
//@}
another, identical, element is in the array.
*/
int Index(T& item, bool searchFromEnd = false) const;
+
/**
This version of Index() is for wxSortedArray only.
- Searches the element in the array, starting from either beginning or
- the end depending on the value of @a searchFromEnd parameter.
+ Searches for the element in the array, using binary search.
+
@c wxNOT_FOUND is returned if the element is not found, otherwise the
index of the element is returned.
*/
- const int Index(T& item) const;
+ int Index(T& item) const;
/**
Search for a place to insert @a item into the sorted array (binary
/**
- This macro may be used to append all elements of the @a other array to the
- @a array. The two arrays must be of the same type.
+ This macro may be used to append all elements of the @a wxArray_arrayToBeAppended
+ array to the @a wxArray_arrayToModify. The two arrays must be of the same type.
*/
-#define WX_APPEND_ARRAY(wxArray& array, wxArray& other)
+#define WX_APPEND_ARRAY(wxArray_arrayToModify, wxArray_arrayToBeAppended)
/**
This macro may be used to delete all elements of the array before emptying
- it. It can not be used with wxObjArrays - but they will delete their
+ it. It cannot be used with wxObjArrays - but they will delete their
elements anyway when you call Empty().
*/
-#define WX_CLEAR_ARRAY(wxArray& array)
+#define WX_CLEAR_ARRAY(wxArray_arrayToBeCleared)
//@{
/**
//@}
/**
- This macro may be used to prepend all elements of the @a other array to the
- @a array. The two arrays must be of the same type.
+ This macro may be used to prepend all elements of the @a wxArray_arrayToBePrepended
+ array to the @a wxArray_arrayToModify. The two arrays must be of the same type.
*/
-#define WX_PREPEND_ARRAY(wxArray& array, wxArray& other)
+#define WX_PREPEND_ARRAY(wxArray_arrayToModify, wxArray_arrayToBePrepended)
+//@{
+/**
+ Predefined specialization of wxArray<T> for standard types.
+*/
+typedef wxArray<int> wxArrayInt;
+typedef wxArray<long> wxArrayLong;
+typedef wxArray<short> wxArrayShort;
+typedef wxArray<double> wxArrayDouble;
+typedef wxArray<void*> wxArrayPtrVoid;
+//@}