X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7d9d249be4bae53dd16f0a8ac044914c1410c90c..0bd2681966523df88ad5cf8e505b532843e58d74:/docs/latex/wx/array.tex diff --git a/docs/latex/wx/array.tex b/docs/latex/wx/array.tex index 91792f981d..7bd807ecad 100644 --- a/docs/latex/wx/array.tex +++ b/docs/latex/wx/array.tex @@ -56,8 +56,7 @@ int, long and their unsigned variants) or pointers (of any kind). An attempt to use with objects of sizeof() greater than sizeof(long) will provoke a runtime assertion failure, however declaring a wxArray of floats will not (on the machines where sizeof(float) <= sizeof(long)), yet it will {\bf not} work, -please use wxObjArray for storing floats and doubles (NB: a more efficient -wxArrayDouble class is scheduled for the next release of wxWidgets). +please use wxObjArray for storing floats and doubles. wxSortedArray is a wxArray variant which should be used when searching in the array is a frequently used operation. It requires you to define an additional @@ -128,15 +127,19 @@ Things are much simpler for wxArray and wxSortedArray however: it is enough just to write \begin{verbatim} -WX_DEFINE_ARRAY(int, ArrayOfDirectories); -WX_DEFINE_SORTED_ARRAY(int, ArrayOfFiles); +WX_DEFINE_ARRAY_INT(int, ArrayOfInts); +WX_DEFINE_SORTED_ARRAY_INT(int, ArrayOfSortedInts); \end{verbatim} i.e. there is only one {\tt DEFINE} macro and no need for separate -{\tt DECLARE} one. +{\tt DECLARE} one. For the arrays of the primitive types, the macros +{\tt WX\_DEFINE\_ARRAY\_CHAR/SHORT/INT/SIZE\_T/LONG/DOUBLE} should be used +depending on the sizeof of the values (notice that storing values of smaller +type, e.g. shorts, in an array of larger one, e.g. {\tt ARRAY\_INT}, does +\emph{not} work on all architectures!). -\wxheading{See also:} +\wxheading{See also} \helpref{Container classes overview}{wxcontaineroverview}, \helpref{wxList}{wxlist} @@ -145,6 +148,13 @@ i.e. there is only one {\tt DEFINE} macro and no need for separate for wxArray and wxSortedArray and additionally for wxObjArray. +\wxheading{Library} + +\helpref{wxBase}{librarieslist} + + + + \latexignore{\rtfignore{\wxheading{Function groups}}} \membersection{Macros for template array definition}\label{arraymacros} @@ -239,7 +249,6 @@ Functions in this section return the total number of array elements and allow to retrieve them - possibly using just the C array indexing $[]$ operator which does exactly the same as \helpref{Item()}{wxarrayitem} method. -\helpref{Count}{wxarraycount}\\ \helpref{GetCount}{wxarraygetcount}\\ \helpref{IsEmpty}{wxarrayisempty}\\ \helpref{Item}{wxarrayitem}\\ @@ -250,7 +259,8 @@ does exactly the same as \helpref{Item()}{wxarrayitem} method. \helpref{Add}{wxarrayadd}\\ \helpref{Insert}{wxarrayinsert}\\ \helpref{SetCount}{wxarraysetcount}\\ -\helpref{WX\_APPEND\_ARRAY}{wxappendarray} +\helpref{WX\_APPEND\_ARRAY}{wxappendarray}\\ +\helpref{WX\_PREPEND\_ARRAY}{wxprependarray} \membersection{Removing items}\label{arrayremoving} @@ -294,8 +304,9 @@ class MyClass; WX_DEFINE_ARRAY(MyClass *, ArrayOfMyClass); \end{verbatim} -Note that wxWidgets predefines the following standard array classes: wxArrayInt, -wxArrayLong and wxArrayPtrVoid. +Note that wxWidgets predefines the following standard array classes: {\bf wxArrayInt}, +{\bf wxArrayLong}, {\bf wxArrayShort}, {\bf wxArrayDouble}, {\bf wxArrayPtrVoid}. + \membersection{WX\_DEFINE\_SORTED\_ARRAY}\label{wxdefinesortedarray} @@ -405,6 +416,13 @@ WX_DEFINE_OBJARRAY(wxArrayOfMyClass); This macro may be used to append all elements of the {\it other} array to the {\it array}. The two arrays must be of the same type. +\membersection{WX\_PREPEND\_ARRAY}\label{wxprependarray} + +\func{void}{WX\_PREPEND\_ARRAY}{\param{wxArray\& }{array}, \param{wxArray\& }{other}} + +This macro may be used to prepend all elements of the {\it other} array to the +{\it array}. The two arrays must be of the same type. + \membersection{WX\_CLEAR\_ARRAY}\label{wxcleararray} \func{void}{WX\_CLEAR\_ARRAY}{\param{wxArray\& }{array}} @@ -493,7 +511,8 @@ append a lot of items. Preallocates memory for a given number of array elements. It is worth calling when the number of items which are going to be added to the array is known in advance because it will save unneeded memory reallocation. If the array already -has enough memory for the given number of items, nothing happens. +has enough memory for the given number of items, nothing happens. In any case, +the existing contents of the array is not modified. \membersection{wxArray::Clear}\label{wxarrayclear} @@ -502,13 +521,6 @@ has enough memory for the given number of items, nothing happens. This function does the same as \helpref{Empty()}{wxarrayempty} and additionally frees the memory allocated to the array. -\membersection{wxArray::Count}\label{wxarraycount} - -\constfunc{size\_t}{Count}{\void} - -Same as \helpref{GetCount()}{wxarraygetcount}. This function is deprecated - -it exists only for compatibility. - \membersection{wxObjArray::Detach}\label{wxobjarraydetach} \func{T *}{Detach}{\param{size\_t }{index}} @@ -534,9 +546,9 @@ Return the number of items in the array. \membersection{wxArray::Index}\label{wxarrayindex} -\func{int}{Index}{\param{T\& }{item}, \param{bool }{searchFromEnd = false}} +\constfunc{int}{Index}{\param{T\& }{item}, \param{bool }{searchFromEnd = false}} -\func{int}{Index}{\param{T\& }{item}} +\constfunc{int}{Index}{\param{T\& }{item}} The first version of the function is for wxArray and wxObjArray, the second is for wxSortedArray only. @@ -679,3 +691,4 @@ return a negative, zero or positive value according to whether the first element passed to it is less than, equal to or greater than the second one. wxSortedArray doesn't have this function because it is always sorted. +