#define _XBT_DYNAR_H
#include "xbt/misc.h" /* SG_BEGIN_DECL */
+#include "xbt/function_types.h"
SG_BEGIN_DECL()
-/** \addtogroup XBT_dynar
+/** @addtogroup XBT_dynar
+ * @brief DynArr are dynamically sized vector which may contain any type of variables.
+ *
+ * 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
* 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
* \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
+ *
* @{
*/
/** \brief Dynar data type (opaque type) */
xbt_dynar_t xbt_dynar_new(unsigned long elm_size,
void_f_pvoid_t *free_func);
void xbt_dynar_free(xbt_dynar_t *dynar);
+ void xbt_dynar_free_voidp(void *dynar);
void xbt_dynar_free_container(xbt_dynar_t *dynar);
unsigned long xbt_dynar_length(const xbt_dynar_t dynar);
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
+ *
* @{
*/
void xbt_dynar_insert_at(xbt_dynar_t dynar, int idx, const void *src);
void xbt_dynar_remove_at(xbt_dynar_t dynar, int idx, void * const dst);
+ int xbt_dynar_search(xbt_dynar_t dynar, void *elem);
+ int xbt_dynar_member(xbt_dynar_t dynar, void *elem);
/** @} */
-/** @name 2. Perl-like functions
+/** @defgroup XBT_dynar_perl Perl-like use of dynars
+ * @ingroup XBT_dynar
+ *
* @{
*/
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
*
- * Those functions do not retrive the content, but only their address.
+ * Those functions do not retrieve the content, but only their address.
*
* @{
*/
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
*
- * While the other functions use a memcpy to retrive the content into the
+ * While the other functions use a memcpy to retrieve the content into the
* user provided area, those ones use a regular affectation. It only works
* for scalar values, but should be a little faster.
*
/** @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) \
/** @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
*
* Cursors are used to iterate over the structure. Never add elements to the
* DynArr during the traversal. To remove elements, use the
xbt_dynar_cursor_get(_dynar,&(_cursor),&_data) ; \
xbt_dynar_cursor_step(_dynar,&(_cursor)) )
+/** @} */
SG_END_DECL()
-/* @} */
#endif /* _XBT_DYNAR_H */