#include <xbt/base.h> /* SG_BEGIN_DECL */
#include <xbt/function_types.h>
-SG_BEGIN_DECL()
+SG_BEGIN_DECL
/** @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
+ * For performance concerns, the content of DynArr must be homogeneous (in contrary to dictionaries -- see the
* @ref XBT_dict section). You thus have to provide the function which will be used to free the content at
* structure creation (of type void_f_pvoid_t).
*
XBT_PUBLIC signed int xbt_dynar_search_or_negative(xbt_dynar_t const dynar, void* const elem);
XBT_PUBLIC int xbt_dynar_member(xbt_dynar_t const dynar, void* elem);
XBT_PUBLIC void xbt_dynar_sort(xbt_dynar_t const dynar, int_f_cpvoid_cpvoid_t compar_fn);
-XBT_PUBLIC xbt_dynar_t xbt_dynar_sort_strings(xbt_dynar_t dynar);
XBT_PUBLIC int xbt_dynar_compare(xbt_dynar_t d1, xbt_dynar_t d2, int (*compar)(const void*, const void*));
XBT_PUBLIC void* xbt_dynar_to_array(xbt_dynar_t dynar);
(*(type*)xbt_dynar_get_ptr((dynar),(idx)))
/** @brief Quick setting of scalar content
* @hideinitializer */
-# define xbt_dynar_set_as(dynar,idx,type,val) \
- (*(type*)xbt_dynar_set_at_ptr((dynar),(idx))) = val
- /** @brief Quick retrieval of scalar content
- * @hideinitializer */
+#define xbt_dynar_set_as(dynar, idx, type, val) (*(type*)xbt_dynar_set_at_ptr((dynar), (idx))) = (val)
+/** @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 */
+/** @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 removal of scalar content
- * @hideinitializer */
+/** @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 removal of scalar content
+ * @hideinitializer */
# define xbt_dynar_pop_as(dynar,type) \
(*(type*)xbt_dynar_pop_ptr(dynar))
* Note that underneath, that's a simple for loop with no real black magic involved. It's perfectly safe to interrupt
* a foreach with a break or a return statement.
*/
-#define xbt_dynar_foreach(_dynar,_cursor,_data) \
- for ( (_cursor) = 0 ; \
- _xbt_dynar_cursor_get(_dynar,_cursor,&_data) ; \
- (_cursor)++ )
+#define xbt_dynar_foreach(_dynar, _cursor, _data) \
+ for ((_cursor) = 0; _xbt_dynar_cursor_get((_dynar), (_cursor), &(_data)); (_cursor)++)
#ifndef __cplusplus
-#define xbt_dynar_foreach_ptr(_dynar,_cursor,_ptr) \
- for ((_cursor) = 0 ; \
- (_ptr = _cursor < _dynar->used ? xbt_dynar_get_ptr(_dynar,_cursor) : NULL) ; \
- (_cursor)++ )
+#define xbt_dynar_foreach_ptr(_dynar, _cursor, _ptr) \
+ for ((_cursor) = 0; ((_ptr) = (_cursor) < (_dynar)->used ? xbt_dynar_get_ptr((_dynar), (_cursor)) : NULL); \
+ (_cursor)++)
#else
-#define xbt_dynar_foreach_ptr(_dynar,_cursor,_ptr) \
- for ((_cursor) = 0 ; \
- (_ptr = _cursor < _dynar->used ? (decltype(_ptr)) xbt_dynar_get_ptr(_dynar,_cursor) : NULL) ; \
- (_cursor)++ )
+#define xbt_dynar_foreach_ptr(_dynar, _cursor, _ptr) \
+ for ((_cursor) = 0; \
+ ((_ptr) = (_cursor) < (_dynar)->used ? (decltype(_ptr))xbt_dynar_get_ptr((_dynar), (_cursor)) : NULL); \
+ (_cursor)++)
#endif
/** @} */
-SG_END_DECL()
+SG_END_DECL
#endif /* XBT_DYNAR_H */