/////////////////////////////////////////////////////////////////////////////
/**
- @class wxArrayT
@wxheader{dynarray.h}
This section describes the so called @e dynamic arrays. This is a C
@library{wxbase}
@category{FIXME}
- @see @ref overview_wxcontaineroverview, wxListT(), wxVectorT()
+ @see @ref overview_container, wxList<T>, wxVector<T>
*/
class wxArray<T>
{
/**
wxArray::Add
-
+
wxArray::AddAt
-
+
wxArray::Insert
-
+
wxArray::SetCount
-
+
WX_APPEND_ARRAY()
-
+
WX_PREPEND_ARRAY()
*/
never use wxBaseArray anyhow it shouldn't be a problem) and that you should not
derive your own classes from the array classes.
@ref wxArray::ctordef "wxArray default constructor"
-
+
@ref wxArray::ctorcopy "wxArray copy constructors and assignment operators"
-
+
@ref wxArray::dtor ~wxArray
*/
Linear search is used for the wxArray and wxObjArray classes but binary search
in the sorted array is used for wxSortedArray (this is why searchFromEnd
parameter doesn't make sense for it).
- @b NB: even for wxObjArray classes, the operator==() of the elements in the
+ @note even for wxObjArray classes, the operator==() of the elements in the
array is @b not used by this function. It searches exactly the given
element in the array and so will only succeed if this element had been
previously added to the array, but fail even if another, identical, element is
WX_DECLARE_OBJARRAY macros and must be fully declared before you use
WX_DEFINE_OBJARRAY macro.
WX_DEFINE_ARRAY()
-
+
WX_DEFINE_EXPORTED_ARRAY()
-
+
WX_DEFINE_USER_EXPORTED_ARRAY()
-
+
WX_DEFINE_SORTED_ARRAY()
-
+
WX_DEFINE_SORTED_EXPORTED_ARRAY()
-
+
WX_DEFINE_SORTED_USER_EXPORTED_ARRAY()
-
+
WX_DECLARE_EXPORTED_OBJARRAY()
-
+
WX_DECLARE_USER_EXPORTED_OBJARRAY()
-
+
WX_DEFINE_OBJARRAY()
-
+
WX_DEFINE_EXPORTED_OBJARRAY()
-
+
WX_DEFINE_USER_EXPORTED_OBJARRAY()
To slightly complicate the matters even further, the operator - defined by
default for the array iterators by these macros only makes sense if the array
provokes warnings from some compilers and to avoid them you should use the
@c _PTR versions of the macros above. For example, to define an array of
pointers to @c double you should use:
-
+
Note that the above macros are generally only useful for
wxObject types. There are separate macros for declaring an array of a simple
type,
such as an int.
The following simple types are supported:
-
+
int
-
+
long
-
+
size_t
-
+
double
To create an array of a simple type, simply append the type you want in CAPS to
the array definition.
For example, for an integer array, you'd use one of the following variants:
WX_DEFINE_ARRAY_INT()
-
+
WX_DEFINE_EXPORTED_ARRAY_INT()
-
+
WX_DEFINE_USER_EXPORTED_ARRAY_INT()
-
+
WX_DEFINE_SORTED_ARRAY_INT()
-
+
WX_DEFINE_SORTED_EXPORTED_ARRAY_INT()
-
+
WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_INT()
*/
going to put in the array and will prevent the array code from reallocating the
memory more times than needed.
wxArray::Alloc
-
+
wxArray::Shrink
*/
retrieve them - possibly using just the C array indexing [] operator which
does exactly the same as wxArray::Item method.
wxArray::GetCount
-
+
wxArray::IsEmpty
-
+
wxArray::Item
-
+
wxArray::Last
*/
Detach() 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 it manually if required:
-
+
See also WX_CLEAR_ARRAY() macro which deletes all
elements of a wxArray (supposed to contain pointers).
*/
Detach() 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 it manually if required:
-
+
See also WX_CLEAR_ARRAY() macro which deletes all
elements of a wxArray (supposed to contain pointers).
*/
/**
WX_CLEAR_ARRAY()
-
+
wxArray::Empty
-
+
wxArray::Clear
-
+
wxArray::RemoveAt
-
+
wxArray::Remove
*/
/**
wxArray::Index
-
+
wxArray::IndexForInsert
-
+
wxArray::Sort
*/
@e count. If the array has already @a count or more items, nothing is
done. Otherwise, @c count - GetCount() elements are added and initialized to
the value @e defval.
-
+
@see wxArray::GetCount
*/
void SetCount(size_t count);
/**
The notation CMPFUNCT should be read as if we had the following declaration:
-
+
where @e T is the type of the array elements. I.e. it is a function returning
@e int which is passed two arguments of type @e T *.
Sorts the array using the specified compare function: this function should
*/
void Sort(CMPFUNC<T> compareFunction);
- /**
- This macro may be used to append all elements of the @a other array to the
- @e array. The two arrays must be of the same type.
- */
-#define void WX_APPEND_ARRAY(wxArray& array, wxArray& other) /* implementation is private */
-
- /**
- 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 anyhow
- when you call Empty().
- */
-#define void WX_CLEAR_ARRAY(wxArray& array) /* implementation is private */
-
- //@{
- /**
- This macro declares a new object array class named @a name and containing
- the elements of type @e T. The second form is used when compiling wxWidgets as
- a DLL under Windows and array needs to be visible outside the DLL. The third is
- needed for exporting an array from a user DLL.
- Example:
-
- You must use WX_DEFINE_OBJARRAY() macro to define
- the array class - otherwise you would get link errors.
- */
- WX_DECLARE_OBJARRAY(T, name);
- WX_DECLARE_EXPORTED_OBJARRAY(T, name);
- WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name);
- //@}
-
- //@{
- /**
- This macro defines a new array class named @a name and containing the
- elements of type @e T. The second form is used when compiling wxWidgets as
- a DLL under Windows and array needs to be visible outside the DLL. The third is
- needed for exporting an array from a user DLL.
- Example:
-
- Note that wxWidgets predefines the following standard array classes: @b
- wxArrayInt,
- @b wxArrayLong, @b wxArrayShort, @b wxArrayDouble, @b wxArrayPtrVoid.
- */
- WX_DEFINE_ARRAY(T, name);
- WX_DEFINE_EXPORTED_ARRAY(T, name);
- WX_DEFINE_USER_EXPORTED_ARRAY(T, name, exportspec);
- //@}
-
- //@{
- /**
- This macro defines the methods of the array class @a name not defined by the
- WX_DECLARE_OBJARRAY() macro. You must include the
- file wx/arrimpl.cpp before using this macro and you must have the full
- declaration of the class of array elements in scope! If you forget to do the
- first, the error will be caught by the compiler, but, unfortunately, many
- compilers will not give any warnings if you forget to do the second - but the
- objects of the class will not be copied correctly and their real destructor will
- not be called. The latter two forms are merely aliases of the first to satisfy
- some people's sense of symmetry when using the exported declarations.
- Example of usage:
- */
- WX_DEFINE_OBJARRAY(name);
- WX_DEFINE_EXPORTED_OBJARRAY(name);
- WX_DEFINE_USER_EXPORTED_OBJARRAY(name);
- //@}
-
- //@{
- /**
- This macro defines a new sorted array class named @a name and containing
- the elements of type @e T. The second form is used when compiling wxWidgets as
- a DLL under Windows and array needs to be visible outside the DLL. The third is
- needed for exporting an array from a user DLL.
- Example:
-
- You will have to initialize the objects of this class by passing a comparison
- function to the array object constructor like this:
- */
- WX_DEFINE_SORTED_ARRAY(T, name);
- WX_DEFINE_SORTED_EXPORTED_ARRAY(T, name);
- WX_DEFINE_SORTED_USER_EXPORTED_ARRAY(T, name);
- //@}
-
- /**
- This macro may be used to prepend all elements of the @a other array to the
- @e array. The two arrays must be of the same type.
- */
-#define void WX_PREPEND_ARRAY(wxArray& array, wxArray& other) /* implementation is private */
-
//@{
/**
The copy constructors and assignment operators perform a shallow array copy
//@}
};
+
+/**
+ This macro may be used to append all elements of the @a other array to the
+ @e array. The two arrays must be of the same type.
+*/
+#define WX_APPEND_ARRAY(wxArray& array, wxArray& other) /* implementation is private */
+
+/**
+ 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 anyhow
+ when you call Empty().
+*/
+#define WX_CLEAR_ARRAY(wxArray& array) /* implementation is private */
+
+//@{
+/**
+ This macro declares a new object array class named @a name and containing
+ the elements of type @e T. The second form is used when compiling wxWidgets as
+ a DLL under Windows and array needs to be visible outside the DLL. The third is
+ needed for exporting an array from a user DLL.
+ Example:
+
+ You must use WX_DEFINE_OBJARRAY() macro to define
+ the array class - otherwise you would get link errors.
+*/
+#define WX_DECLARE_OBJARRAY(T, name) /* implementation is private */
+#define WX_DECLARE_EXPORTED_OBJARRAY(T, name) /* implementation is private */
+#define WX_DECLARE_USER_EXPORTED_OBJARRAY(T, name) /* implementation is private */
+//@}
+
+//@{
+/**
+ This macro defines a new array class named @a name and containing the
+ elements of type @e T. The second form is used when compiling wxWidgets as
+ a DLL under Windows and array needs to be visible outside the DLL. The third is
+ needed for exporting an array from a user DLL.
+ Example:
+
+ Note that wxWidgets predefines the following standard array classes: @b
+ wxArrayInt,
+ @b wxArrayLong, @b wxArrayShort, @b wxArrayDouble, @b wxArrayPtrVoid.
+*/
+#define WX_DEFINE_ARRAY(T, name) /* implementation is private */
+#define WX_DEFINE_EXPORTED_ARRAY(T, name) /* implementation is private */
+#define WX_DEFINE_USER_EXPORTED_ARRAY(T, name, exportspec) /* implementation is private */
+//@}
+
+//@{
+/**
+ This macro defines the methods of the array class @a name not defined by the
+ WX_DECLARE_OBJARRAY() macro. You must include the
+ file wx/arrimpl.cpp before using this macro and you must have the full
+ declaration of the class of array elements in scope! If you forget to do the
+ first, the error will be caught by the compiler, but, unfortunately, many
+ compilers will not give any warnings if you forget to do the second - but the
+ objects of the class will not be copied correctly and their real destructor will
+ not be called. The latter two forms are merely aliases of the first to satisfy
+ some people's sense of symmetry when using the exported declarations.
+ Example of usage:
+*/
+#define WX_DEFINE_OBJARRAY(name) /* implementation is private */
+#define WX_DEFINE_EXPORTED_OBJARRAY(name) /* implementation is private */
+#define WX_DEFINE_USER_EXPORTED_OBJARRAY(name) /* implementation is private */
+//@}
+
+//@{
+/**
+ This macro defines a new sorted array class named @a name and containing
+ the elements of type @e T. The second form is used when compiling wxWidgets as
+ a DLL under Windows and array needs to be visible outside the DLL. The third is
+ needed for exporting an array from a user DLL.
+ Example:
+
+ You will have to initialize the objects of this class by passing a comparison
+ function to the array object constructor like this:
+*/
+#define WX_DEFINE_SORTED_ARRAY(T, name) /* implementation is private */
+#define WX_DEFINE_SORTED_EXPORTED_ARRAY(T, name) /* implementation is private */
+#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY(T, name) /* implementation is private */
+//@}
+
+/**
+ This macro may be used to prepend all elements of the @a other array to the
+ @e array. The two arrays must be of the same type.
+*/
+#define WX_PREPEND_ARRAY(wxArray& array, wxArray& other) /* implementation is private */