/////////////////////////////////////////////////////////////////////////////
/**
- @wxheader{dynarray.h}
This section describes the so called @e "dynamic arrays". This is a C
array-like type safe data structure i.e. the member access time is constant
- 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:
Default constructor.
*/
wxArray();
+
/**
Default constructor initializes an empty array object.
*/
wxObjArray();
+
/**
There is no default constructor for wxSortedArray classes - you must
initialize it with a function to use for item comparison. It is a
even if the source array contains the items of pointer type).
*/
wxArray(const wxArray& array);
+
/**
Performs a shallow array copy (i.e. doesn't copy the objects pointed to
even if the source array contains the items of pointer type).
*/
wxSortedArray(const wxSortedArray& array);
+
/**
Performs a deep copy (i.e. the array element are copied too).
*/
even if the source array contains the items of pointer type).
*/
wxArray& operator=(const wxArray& array);
+
/**
Performs a shallow array copy (i.e. doesn't copy the objects pointed to
even if the source array contains the items of pointer type).
*/
wxSortedArray& operator=(const wxSortedArray& array);
+
/**
Performs a deep copy (i.e. the array element are copied too).
*/
may use the WX_CLEAR_ARRAY() macro for this.
*/
~wxArray();
+
/**
This destructor does not delete all the items owned by the array, you
may use the WX_CLEAR_ARRAY() macro for this.
*/
~wxSortedArray();
+
/**
This destructor deletes all the items owned by the array.
*/
a lot of items.
*/
void Add(T item, size_t copies = 1);
+
/**
Appends the @a item to the array consisting of the elements of type
@c T.
@a item is stored.
*/
size_t Add(T item);
+
/**
Appends the @a item to the array consisting of the elements of type
@c T.
This version is used with wxObjArray. The array will take ownership of
- the @item, deleting it when the item is deleted from the array. Note
+ the @a item, deleting it when the item is deleted from the array. Note
that you cannot append more than one pointer as reusing it would lead
to deleting it twice (or more) resulting in a crash.
a lot of items.
*/
void Add(T* item);
+
/**
Appends the given number of @a copies of the @a item to the array
consisting of the elements of type @c T.
overloaded versions of this function.
*/
void Insert(T item, size_t n, size_t copies = 1);
+
/**
Insert the @a item into the array before the existing item @a n - thus,
@e Insert(something, 0u) will insert an item in such way that it will
overloaded versions of this function.
*/
void Insert(T* item, size_t n);
+
/**
Insert the given number of @a copies of the @a item into the array
before the existing item @a n - thus, @e Insert(something, 0u) will
@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).
+
+ @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.
@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
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;
+//@}