-#define gras_dynar_foreach(_dynar,_cursor,_data) \
- for (gras_dynar_cursor_first(_dynar,&(_cursor)) ; \
- gras_dynar_cursor_get(_dynar,&(_cursor),&_data) ; \
- gras_dynar_cursor_step(_dynar,&(_cursor)) )
-/*
- for (gras_dynar_length(_dynar) && (_gras_dynar_cursor_first(_dynar,&_cursor), \
- 1); \
- gras_dynar_length(_dynar) && gras_dynar_cursor_get(_dynar,&_cursor,&_data); \
- gras_dynar_cursor_step(_dynar,&_cursor))
-*/
-void gras_dynar_cursor_rm(gras_dynar_t * dynar,
- int * const cursor);
-
-#endif /* _GRAS_DYNAR_H */
+
+ XBT_PUBLIC(void) xbt_dynar_push (xbt_dynar_t const dynar, const void *src);
+ XBT_PUBLIC(void) xbt_dynar_pop (xbt_dynar_t const dynar, void *const dst);
+ XBT_PUBLIC(void) xbt_dynar_unshift (xbt_dynar_t const dynar, const void *src);
+ XBT_PUBLIC(void) xbt_dynar_shift (xbt_dynar_t const dynar, void *const dst);
+ XBT_PUBLIC(void) xbt_dynar_map (const xbt_dynar_t dynar, void_f_pvoid_t const op);
+
+/** @} */
+/** @defgroup XBT_dynar_ctn Direct manipulation to the dynars content
+ * @ingroup XBT_dynar
+ *
+ * Those functions do not retrieve the content, but only their address.
+ *
+ * @{
+ */
+
+ XBT_PUBLIC(void*) xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx);
+ XBT_PUBLIC(void*) xbt_dynar_insert_at_ptr(xbt_dynar_t const dynar, const int idx);
+ XBT_PUBLIC(void*) xbt_dynar_push_ptr(xbt_dynar_t const dynar);
+ XBT_PUBLIC(void*) xbt_dynar_pop_ptr(xbt_dynar_t const dynar);
+
+/** @} */
+/** @defgroup XBT_dynar_speed Speed optimized access to dynars of scalars
+ * @ingroup XBT_dynar
+ *
+ * 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)))
+ /** @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) \
+ *(type*)xbt_dynar_insert_at_ptr(dynar,idx)=value
+ /** @brief Quick insertion of scalar content
+ * @hideinitializer */
+# define xbt_dynar_push_as(dynar,type,value) \
+ *(type*)xbt_dynar_push_ptr(dynar)=value
+ /** @brief Quick insertion of scalar content
+ * @hideinitializer */
+# define xbt_dynar_pop_as(dynar,type) \
+ (*(type*)xbt_dynar_pop_ptr(dynar))
+
+/** @} */
+/** @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_rm() function.
+ *
+ * Do not call these functions directly, but only the xbt_dynar_foreach macro.
+ *
+ * For synchronized dynars, the dynar will be locked during the whole
+ * loop and it will get unlocked automatically if you traverse all
+ * elements. If you want to break the loop before the end, make sure
+ * to call xbt_dynar_cursor_unlock() before the <tt>break;</tt>
+ *
+ * @{
+ */
+
+ XBT_PUBLIC(void) _xbt_dynar_cursor_first (const xbt_dynar_t dynar, unsigned int * const cursor);
+ XBT_PUBLIC(void) _xbt_dynar_cursor_step (const xbt_dynar_t dynar, unsigned int * const cursor);
+ XBT_PUBLIC(int) _xbt_dynar_cursor_get (const xbt_dynar_t dynar, unsigned int * const cursor,
+ void *whereto);
+ XBT_PUBLIC(void) xbt_dynar_cursor_rm(xbt_dynar_t dynar,
+ unsigned int *const cursor);
+ XBT_PUBLIC(void) xbt_dynar_cursor_unlock(xbt_dynar_t dynar);
+
+/** @brief Iterates over the whole dynar.
+ *
+ * @param _dynar what to iterate over
+ * @param _cursor an integer used as cursor
+ * @param _data
+ * @hideinitializer
+ *
+ * \note An example of usage:
+ * \code
+xbt_dynar_t dyn;
+unsigned int cpt;
+string *str;
+xbt_dynar_foreach (dyn,cpt,str) {
+ printf("Seen %s\n",str);
+}
+\endcode
+ */
+#define xbt_dynar_foreach(_dynar,_cursor,_data) \
+ for (_xbt_dynar_cursor_first(_dynar,&(_cursor)) ; \
+ _xbt_dynar_cursor_get(_dynar,&(_cursor),&_data) ; \
+ _xbt_dynar_cursor_step(_dynar,&(_cursor)) )
+
+/** @} */
+
+SG_END_DECL()
+
+#endif /* _XBT_DYNAR_H */