X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e87271f35887a50e011c7c97fc63c35f5d623e50..85136e3bf5dadf921652519e71da5db351fb3194:/docs/latex/wx/arrstrng.tex diff --git a/docs/latex/wx/arrstrng.tex b/docs/latex/wx/arrstrng.tex index 62f1f245e6..fc5877f8cb 100644 --- a/docs/latex/wx/arrstrng.tex +++ b/docs/latex/wx/arrstrng.tex @@ -12,7 +12,7 @@ uses its knowledge of internals of wxString class to achieve this). This class is used in the same way as other dynamic \helpref{arrays}{wxarray}, except that no {\it WX\_DEFINE\_ARRAY} declaration is needed for it. When a string is added or inserted in the array, a copy of the string is created, so -the original string may be safely deleted (e.g. if it was a {\it char *} +the original string may be safely deleted (e.g. if it was a {\it wxChar *} pointer the memory it was using can be freed immediately after this). In general, there is no need to worry about string memory deallocation when using this class - it will always free the memory it uses itself. @@ -26,14 +26,14 @@ array elements may be modified in place like this array.Last().MakeUpper(); \end{verbatim} -There is also a varian of wxArrayString called wxSortedArrayString which has +There is also a variant of wxArrayString called wxSortedArrayString which has exactly the same methods as wxArrayString, but which always keeps the string in it in (alphabetical) order. wxSortedArrayString uses binary search in its -\helpref{Index}{wxarraystringindex} function (insteadf of linear search for +\helpref{Index}{wxarraystringindex} function (instead of linear search for wxArrayString::Index) which makes it much more efficient if you add strings to the array rarely (because, of course, you have to pay for Index() efficiency by having Add() be slower) but search for them often. Several methods should -not be used with sorted array (basicly, all which break the order of items) +not be used with sorted array (basically, all which break the order of items) which is mentioned in their description. Final word: none of the methods of wxArrayString is virtual including its @@ -48,7 +48,11 @@ functions. \wxheading{Include files} - + + +\wxheading{Library} + +\helpref{wxBase}{librarieslist} \wxheading{See also} @@ -60,13 +64,23 @@ functions. \func{}{wxArrayString}{\void} -\func{}{wxArrayString}{\param{const wxArrayString\&}{ array}} +Default constructor. -Default and copy constructors. +\func{}{wxArrayString}{\param{const wxArrayString\&}{ array}} -Note that when an array is assigned to a sorted array, its contents is +Copy constructor. Note that when an array is assigned to a sorted array, its contents is automatically sorted during construction. +\func{}{wxArrayString}{\param{size\_t}{ sz}, \param{const char**}{ arr}} + +\func{}{wxArrayString}{\param{size\_t}{ sz}, \param{const wchar\_t**}{ arr}} + +Constructor from a C string array. Pass a size {\it sz} and array {\it arr}. + +\func{}{wxArrayString}{\param{size\_t}{ sz}, \param{const wxString*}{ arr}} + +Constructor from a wxString array. Pass a size {\it sz} and array {\it arr}. + \membersection{wxArrayString::\destruct{wxArrayString}}\label{wxarraystringdtor} \func{}{\destruct{wxArrayString}}{} @@ -80,6 +94,20 @@ reasons it is not virtual, so this class should not be derived from. Assignment operator. +\membersection{wxArrayString::operator==}\label{wxarraystringoperatorequal} + +\constfunc{bool}{operator $==$}{\param{const wxArrayString\&}{ array}} + +Compares 2 arrays respecting the case. Returns true only if the arrays have +the same number of elements and the same strings in the same order. + +\membersection{wxArrayString::operator!=}\label{wxarraystringoperatornotequal} + +\constfunc{bool}{operator $!=$}{\param{const wxArrayString\&}{ array}} + +Compares 2 arrays respecting the case. Returns true if the arrays have +different number of elements or if the elements don't match pairwise. + \membersection{wxArrayString::operator[]}\label{wxarraystringoperatorindex} \func{wxString\&}{operator[]}{\param{size\_t }{nIndex}} @@ -92,9 +120,10 @@ This is the operator version of \helpref{Item}{wxarraystringitem} method. \membersection{wxArrayString::Add}\label{wxarraystringadd} -\func{void}{Add}{\param{const wxString\& }{str}} +\func{size\_t}{Add}{\param{const wxString\& }{str}, \param{size\_t}{ copies = $1$}} -Appends a new item to the array. +Appends the given number of {\it copies} of the new item {\it str} to the +array and returns the index of the first new item in the array. {\bf Warning:} For sorted arrays, the index of the inserted item will not be, in general, equal to \helpref{GetCount()}{wxarraystringgetcount} - 1 because @@ -121,14 +150,6 @@ Clears the array contents and frees memory. See also: \helpref{Empty}{wxarraystringempty} -\membersection{wxArrayString::Count}\label{wxarraystringcount} - -\constfunc{size\_t}{Count}{\void} - -Returns the number of items in the array. This function is deprecated and is -for backwards compatibility only, please use -\helpref{GetCount}{wxarraystringgetcount} instead. - \membersection{wxArrayString::Empty}\label{wxarraystringempty} \func{void}{Empty}{\void} @@ -148,41 +169,41 @@ Returns the number of items in the array. \membersection{wxArrayString::Index}\label{wxarraystringindex} -\func{int}{Index}{\param{const char *}{ sz}, \param{bool}{ bCase = TRUE}, \param{bool}{ bFromEnd = FALSE}} +\func{int}{Index}{\param{const wxString\& }{ sz}, \param{bool}{ bCase = true}, \param{bool}{ bFromEnd = false}} Search the element in the array, starting from the beginning if -{\it bFromEnd} is FALSE or from end otherwise. If {\it bCase}, comparison is +{\it bFromEnd} is false or from end otherwise. If {\it bCase}, comparison is case sensitive (default), otherwise the case is ignored. This function uses linear search for wxArrayString and binary search for wxSortedArrayString, but it ignores the {\it bCase} and {\it bFromEnd} parameters in the latter case. -Returns index of the first item matched or wxNOT\_FOUND if there is no match. +Returns index of the first item matched or {\tt wxNOT\_FOUND} if there is no match. \membersection{wxArrayString::Insert}\label{wxarraystringinsert} -\func{void}{Insert}{\param{const wxString\& }{str}, \param{size\_t}{ nIndex}} +\func{void}{Insert}{\param{const wxString\& }{str}, \param{size\_t}{ nIndex}, \param{size\_t }{copies = $1$}} -Insert a new element in the array before the position {\it nIndex}. Thus, for +Insert the given number of {\it copies} of the new element in the array before the position {\it nIndex}. Thus, for example, to insert the string in the beginning of the array you would write \begin{verbatim} Insert("foo", 0); \end{verbatim} -If {\it nIndex} is equal to {\it GetCount() + 1} this function behaves as +If {\it nIndex} is equal to {\it GetCount()} this function behaves as \helpref{Add}{wxarraystringadd}. -{\bf Warning:} this function should not be used with sorted array because it +{\bf Warning:} this function should not be used with sorted arrays because it could break the order of items and, for example, subsequent calls to -\helpref{Index()}{wxarraystringindex} would not work then! +\helpref{Index()}{wxarraystringindex} would then not work! \membersection{wxArrayString::IsEmpty}\label{wxarraystringisempty} -\func{}{IsEmpty}{} +\func{bool}{IsEmpty}{} -Returns TRUE if the array is empty, FALSE otherwise. This function returns the +Returns true if the array is empty, false otherwise. This function returns the same result as {\it GetCount() == 0} but is probably easier to read. \membersection{wxArrayString::Item}\label{wxarraystringitem} @@ -198,28 +219,26 @@ version. \membersection{wxArrayString::Last}\label{wxarraystringlast} -\func{}{Last}{} +\func{wxString&}{Last}{} Returns the last element of the array. Attempt to access the last element of an empty array will result in assert failure in debug build, however no checks are done in release mode. -\membersection{wxArrayString::Remove (by value)}\label{wxarraystringremoveval} +\membersection{wxArrayString::Remove}\label{wxarraystringremove} -\func{void}{Remove}{\param{const char *}{ sz}} +\func{void}{Remove}{\param{const wxString\&}{ sz}} Removes the first item matching this value. An assert failure is provoked by an attempt to remove an element which does not exist in debug build. -See also: \helpref{Index}{wxarraystringindex}, \helpref{Remove}{wxarraystringremove} - -\membersection{wxArrayString::Remove (by index)}\label{wxarraystringremove} +See also: \helpref{Index}{wxarraystringindex} -\func{void}{Remove}{\param{size\_t }{nIndex}} +\membersection{wxArrayString::RemoveAt}\label{wxarraystringremoveat} -Removes the item at given position. +\func{void}{RemoveAt}{\param{size\_t }{nIndex}, \param{size\_t }{count = $1$}} -See also: \helpref{Remove}{wxarraystringremoveval} +Removes {\it count} items starting at position {\it nIndex} from the array. \membersection{wxArrayString::Shrink}\label{wxarraystringshrink} @@ -230,26 +249,22 @@ minimize the array memory consumption. See also: \helpref{Alloc}{wxarraystringalloc}, \helpref{Dynamic array memory management}{wxarraymemorymanagement} -\membersection{wxArrayString::Sort (alphabetically)}\label{wxarraystringsort} +\membersection{wxArrayString::Sort}\label{wxarraystringsort} -\func{void}{Sort}{\param{bool}{ reverseOrder = FALSE}} +\func{void}{Sort}{\param{bool}{ reverseOrder = false}} -Sorts the array in alphabetical order or in reverse alphabetical order if -{\it reverseOrder} is TRUE. +Sorts the array in alphabetical order or in reverse alphabetical order if +{\it reverseOrder} is true. The sort is case-sensitive. {\bf Warning:} this function should not be used with sorted array because it could break the order of items and, for example, subsequent calls to -\helpref{Index()}{wxarraystringindex} would not work then! - -See also: \helpref{Sort}{wxarraystringsortcallback} - -\membersection{wxArrayString::Sort (user defined)}\label{wxarraystringsortcallback} +\helpref{Index()}{wxarraystringindex} would then not work! \func{void}{Sort}{\param{CompareFunction }{compareFunction}} Sorts the array using the specified {\it compareFunction} for item comparison. {\it CompareFunction} is defined as a function taking two {\it const -wxString\&} parameters and returning {\it int} value less than, equal to or +wxString\&} parameters and returning an {\it int} value less than, equal to or greater than 0 if the first string is less than, equal to or greater than the second one. @@ -277,7 +292,5 @@ array.Sort(CompareStringLen); {\bf Warning:} this function should not be used with sorted array because it could break the order of items and, for example, subsequent calls to -\helpref{Index()}{wxarraystringindex} would not work then! - -See also: \helpref{Sort}{wxarraystringsort} +\helpref{Index()}{wxarraystringindex} would then not work!