X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5a59b3331acf8ba4b86eb3c513147d186bf8fc6c..85897b1307bb68f05f31385803f1b3a5b806a73f:/include/xbt/dynar.h diff --git a/include/xbt/dynar.h b/include/xbt/dynar.h index 2b5fa44ac3..ab156bbb58 100644 --- a/include/xbt/dynar.h +++ b/include/xbt/dynar.h @@ -14,7 +14,16 @@ SG_BEGIN_DECL() -/** \addtogroup XBT_dynar +/** @addtogroup XBT_dynar + * @brief DynArr are dynamically sized vector which may contain any type of variables. + * + *
Up [\ref index]::[\ref XBT_API] + *
Prev [\ref XBT_config] + *
Next [\ref XBT_dict] + *
Down \ref XBT_dynar_cons\n\ref XBT_dynar_array\n\ref XBT_dynar_perl\n\ref XBT_dynar_ctn\n\ref XBT_dynar_speed\n\ref XBT_dynar_cursor + *
+ * + * These are the SimGrid version of the dynamically size arrays, which all C programmer recode one day or another. * * For performance concerns, the content of DynArr must be homogeneous (in * contrary to dictionnaries -- see the \ref XBT_dict section). You thus @@ -22,7 +31,7 @@ SG_BEGIN_DECL() * structure creation (of type void_f_ppvoid_t or void_f_pvoid_t). * * \section XBT_dynar_exscal Example with scalar - * \dontinclude dynar_int.c + * \dontinclude dynar.c * * \skip Vars_decl * \skip dyn @@ -35,22 +44,27 @@ SG_BEGIN_DECL() * \until xbt_dynar_free * * \section XBT_dynar_exptr Example with pointed data - * \dontinclude dynar_string.c * - * \skip doxygen_first_cruft - * \skip f - * \until xbt_init + * \skip doxygen_string_cruft + * \skip function + * \until s2 * \skip Populate_str * \skip dyn * \until } * \skip macro * \until dynar_free - * \skip xbt_exit + * \skip end_of_doxygen * \until } - * @{ + * */ -/** @name 1. Constructor/destructor +/** @defgroup XBT_dynar_cons Dynar constructor and destructor + * @ingroup XBT_dynar + * + *
Up [\ref index]::[\ref XBT_API]::[\ref XBT_dynar] + *
Jump to --\>\ref XBT_dynar_cons\<--\n\ref XBT_dynar_array\n\ref XBT_dynar_perl\n\ref XBT_dynar_ctn\n\ref XBT_dynar_speed\n\ref XBT_dynar_cursor + *
+ * * @{ */ /** \brief Dynar data type (opaque type) */ @@ -68,7 +82,13 @@ SG_BEGIN_DECL() void xbt_dynar_dump(xbt_dynar_t dynar); /** @} */ -/** @name 2. regular array functions +/** @defgroup XBT_dynar_array Dynar as a regular array + * @ingroup XBT_dynar + * + *
Up [\ref index]::[\ref XBT_API]::[\ref XBT_dynar] + *
Jump to \ref XBT_dynar_cons\n--\>\ref XBT_dynar_array\<--\n\ref XBT_dynar_perl\n\ref XBT_dynar_ctn\n\ref XBT_dynar_speed\n\ref XBT_dynar_cursor + *
+ * * @{ */ @@ -81,7 +101,13 @@ SG_BEGIN_DECL() void xbt_dynar_remove_at(xbt_dynar_t dynar, int idx, void * const dst); /** @} */ -/** @name 2. Perl-like functions +/** @defgroup XBT_dynar_perl Perl-like use of dynars + * @ingroup XBT_dynar + * + *
Up [\ref index]::[\ref XBT_API]::[\ref XBT_dynar] + *
Jump to \ref XBT_dynar_cons\n\ref XBT_dynar_array\n--\>\ref XBT_dynar_perl\<--\n\ref XBT_dynar_ctn\n\ref XBT_dynar_speed\n\ref XBT_dynar_cursor + *
+ * * @{ */ @@ -92,7 +118,12 @@ SG_BEGIN_DECL() void xbt_dynar_map (const xbt_dynar_t dynar, void_f_pvoid_t *op); /** @} */ -/** @name 3. Manipulating pointers to the content +/** @defgroup XBT_dynar_ctn Direct manipulation to the dynars content + * @ingroup XBT_dynar + * + *
Up [\ref index]::[\ref XBT_API]::[\ref XBT_dynar] + *
Jump to \ref XBT_dynar_cons\n\ref XBT_dynar_array\n\ref XBT_dynar_perl\n--\>\ref XBT_dynar_ctn\<--\n\ref XBT_dynar_speed\n\ref XBT_dynar_cursor + *
* * Those functions do not retrive the content, but only their address. * @@ -105,7 +136,12 @@ SG_BEGIN_DECL() void *xbt_dynar_pop_ptr(xbt_dynar_t dynar); /** @} */ -/** @name 4. Speed optimized functions for scalars +/** @defgroup XBT_dynar_speed Speed optimized access to dynars of scalars + * @ingroup XBT_dynar + * + *
Up [\ref index]::[\ref XBT_API]::[\ref XBT_dynar] + *
Jump to \ref XBT_dynar_cons\n\ref XBT_dynar_array\n\ref XBT_dynar_perl\n\ref XBT_dynar_ctn\n--\>\ref XBT_dynar_speed\<--\n\ref XBT_dynar_cursor + *
* * While the other functions use a memcpy to retrive the content into the * user provided area, those ones use a regular affectation. It only works @@ -117,7 +153,15 @@ SG_BEGIN_DECL() /** @brief Quick retrieval of scalar content * @hideinitializer */ # define xbt_dynar_get_as(dynar,idx,type) \ - *(type*)xbt_dynar_get_ptr(dynar,idx) + (*(type*)xbt_dynar_get_ptr((dynar),(idx))) + /** @brief Quick retrieval of scalar content + * @hideinitializer */ +# define xbt_dynar_getlast_as(dynar,type) \ + (*(type*)xbt_dynar_get_ptr((dynar),xbt_dynar_length(dynar)-1)) + /** @brief Quick retrieval of scalar content + * @hideinitializer */ +# define xbt_dynar_getfirst_as(dynar,type) \ + (*(type*)xbt_dynar_get_ptr((dynar),0)) /** @brief Quick insertion of scalar content * @hideinitializer */ # define xbt_dynar_insert_at_as(dynar,idx,type,value) \ @@ -129,10 +173,15 @@ SG_BEGIN_DECL() /** @brief Quick insertion of scalar content * @hideinitializer */ # define xbt_dynar_pop_as(dynar,type) \ - *(type*)xbt_dynar_pop_ptr(dynar) + (*(type*)xbt_dynar_pop_ptr(dynar)) /** @} */ -/** @name 5. Cursors on DynArr +/** @defgroup XBT_dynar_cursor Cursors on dynar + * @ingroup XBT_dynar + * + *
Up [\ref index]::[\ref XBT_API]::[\ref XBT_dynar] + *
Jump to \ref XBT_dynar_cons\n\ref XBT_dynar_array\n\ref XBT_dynar_perl\n\ref XBT_dynar_ctn\n\ref XBT_dynar_speed\n--\>\ref XBT_dynar_cursor\<-- + *
* * Cursors are used to iterate over the structure. Never add elements to the * DynArr during the traversal. To remove elements, use the @@ -171,8 +220,8 @@ xbt_dynar_foreach (dyn,cpt,str) { xbt_dynar_cursor_get(_dynar,&(_cursor),&_data) ; \ xbt_dynar_cursor_step(_dynar,&(_cursor)) ) +/** @} */ SG_END_DECL() -/* @} */ #endif /* _XBT_DYNAR_H */