X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4cc4bfafe5a31cb96f35b3ec9b19fa2b0b3a4eef..b02f1c862d1a3fcd714aef37e67decaa9d67b611:/interface/dynarray.h diff --git a/interface/dynarray.h b/interface/dynarray.h index 3f58b6a209..cb5bdb6462 100644 --- a/interface/dynarray.h +++ b/interface/dynarray.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: dynarray.h -// Purpose: documentation for wxArray class +// Purpose: interface of wxArray // Author: wxWidgets team // RCS-ID: $Id$ // Licence: wxWindows license @@ -149,8 +149,7 @@ @library{wxbase} @category{FIXME} - @seealso - @ref overview_wxcontaineroverview, wxListT, wxVectorT + @see @ref overview_wxcontaineroverview, wxListT(), wxVectorT() */ class wxArray { @@ -169,7 +168,7 @@ public: because the other array types never take ownership of their elements. Also note that you cannot append more than one pointer as reusing it would lead to deleting it twice (or more) and hence to a crash. - You may also use WX_APPEND_ARRAY macro to append all + You may also use WX_APPEND_ARRAY() macro to append all elements of one array to another one but it is more efficient to use @a copies parameter and modify the elements in place later if you plan to append a lot of items. @@ -193,16 +192,16 @@ public: /** wxArray::Add - + wxArray::AddAt - + wxArray::Insert - + wxArray::SetCount - - WX_APPEND_ARRAY - - WX_PREPEND_ARRAY + + WX_APPEND_ARRAY() + + WX_PREPEND_ARRAY() */ @@ -231,9 +230,9 @@ public: 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 */ @@ -271,7 +270,7 @@ public: /** Return the number of items in the array. */ - size_t GetCount(); + size_t GetCount() const; //@{ /** @@ -290,8 +289,8 @@ public: previously added to the array, but fail even if another, identical, element is in the array. */ - int Index(T& item, bool searchFromEnd = false); - int Index(T& item); + int Index(T& item, bool searchFromEnd = false) const; + const int Index(T& item) const; //@} /** @@ -304,7 +303,7 @@ public: wxArray::AddAt for a common operation of "insert only if not found". */ - size_t IndexForInsert(T item); + size_t IndexForInsert(T item) const; //@{ /** @@ -324,7 +323,7 @@ public: /** Returns @true if the array is empty, @false otherwise. */ - bool IsEmpty(); + bool IsEmpty() const; /** Returns the item at the given position in the array. If @a index is out of @@ -333,7 +332,7 @@ public: The returned value is of type "reference to the array element type" for all of the array classes. */ - T Item(size_t index); + T Item(size_t index) const; /** Returns the last element in the array, i.e. is the same as Item(GetCount() - 1). @@ -341,7 +340,7 @@ public: The returned value is of type "reference to the array element type" for all of the array classes. */ - T Last(); + T Last() const; /** To use an array you must first define the array class. This is done with the @@ -349,61 +348,61 @@ public: least) forward declared for WX_DEFINE_ARRAY, WX_DEFINE_SORTED_ARRAY and 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 + 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 element type is not a pointer itself and, although it still works, this 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 + 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() */ @@ -421,7 +420,7 @@ public: going to put in the array and will prevent the array code from reallocating the memory more times than needed. wxArray::Alloc - + wxArray::Shrink */ @@ -431,11 +430,11 @@ public: 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 */ @@ -445,11 +444,11 @@ public: array equal to @a item is removed, an assert failure will result from an attempt to remove an item which doesn't exist in the array. When an element is removed from wxObjArray it is deleted by the array - use - Detach if you don't want this to happen. On the + 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 + + See also WX_CLEAR_ARRAY() macro which deletes all elements of a wxArray (supposed to contain pointers). */ Remove(T item); @@ -457,33 +456,33 @@ public: /** Removes @a count elements starting at @a index from the array. When an element is removed from wxObjArray it is deleted by the array - use - Detach if you don't want this to happen. On + 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 + + 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); /** - WX_CLEAR_ARRAY - + WX_CLEAR_ARRAY() + wxArray::Empty - + wxArray::Clear - + wxArray::RemoveAt - + wxArray::Remove */ /** wxArray::Index - + wxArray::IndexForInsert - + wxArray::Sort */ @@ -494,7 +493,7 @@ public: @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); @@ -509,7 +508,7 @@ public: /** 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 @@ -539,8 +538,8 @@ public: 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 + + You must use WX_DEFINE_OBJARRAY() macro to define the array class - otherwise you would get link errors. */ WX_DECLARE_OBJARRAY(T, name); @@ -555,7 +554,7 @@ public: 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. @@ -568,7 +567,7 @@ public: //@{ /** This macro defines the methods of the array class @a name not defined by the - WX_DECLARE_OBJARRAY macro. You must include 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 @@ -590,7 +589,7 @@ public: 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: */ @@ -624,10 +623,11 @@ public: /** The wxObjArray destructor deletes all the items owned by the array. This is not done by wxArray and wxSortedArray versions - you may use - WX_CLEAR_ARRAY macro for this. + WX_CLEAR_ARRAY() macro for this. */ ~wxArray(); ~wxSortedArray(); ~wxObjArray(); //@} }; +