X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b3b356352e87ae00a20f737c48e19b0c8413455a..c46aba70aa4ccf22cc19fac31d451c7158e922dd:/include/xbt/dynar.h diff --git a/include/xbt/dynar.h b/include/xbt/dynar.h index 4ca03cc365..0a9e47f567 100644 --- a/include/xbt/dynar.h +++ b/include/xbt/dynar.h @@ -105,6 +105,7 @@ XBT_PUBLIC(signed int) xbt_dynar_search_or_negative(xbt_dynar_t const dynar, voi 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(void) xbt_dynar_three_way_partition(xbt_dynar_t const dynar, int_f_pvoid_t color); XBT_PUBLIC(int) xbt_dynar_compare(xbt_dynar_t d1, xbt_dynar_t d2, @@ -213,12 +214,14 @@ XBT_PUBLIC(void *) xbt_dynar_pop_ptr(xbt_dynar_t const dynar); XBT_PUBLIC(void) xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int *const cursor); -/* do not use this structure internals directly, but use the public interface - * This was made public to allow: - * - the inlining of the foreach elements - * - sending such beasts over the network +/* + * \warning DO NOT USE THIS STRUCTURE DIRECTLY! Instead, use the public interface: + * This was made public to allow: + * - the inlining of the foreach elements + * - sending such beasts over the network + * + * \see xbt_dynar_length() */ - typedef struct xbt_dynar_s { unsigned long size; unsigned long used; @@ -227,16 +230,6 @@ typedef struct xbt_dynar_s { void_f_pvoid_t free_f; } s_xbt_dynar_t; -static XBT_INLINE void -_xbt_dynar_cursor_first(const xbt_dynar_t dynar _XBT_GNUC_UNUSED, - unsigned int *const cursor) -{ - /* iterating over a NULL dynar is a no-op (but we don't want to have uninitialized counters) */ - - //XBT_DEBUG("Set cursor on %p to the first position", (void *) dynar); - *cursor = 0; -} - static XBT_INLINE int _xbt_dynar_cursor_get(const xbt_dynar_t dynar, unsigned int idx, void *const dst) @@ -280,19 +273,19 @@ xbt_dynar_foreach (dyn,cpt,str) { * break or a return statement. */ #define xbt_dynar_foreach(_dynar,_cursor,_data) \ - for (_xbt_dynar_cursor_first(_dynar,&(_cursor)) ; \ - _xbt_dynar_cursor_get(_dynar,_cursor,&_data) ; \ - (_cursor)++ ) + for ( (_cursor) = 0 ; \ + _xbt_dynar_cursor_get(_dynar,_cursor,&_data) ; \ + (_cursor)++ ) #ifndef __cplusplus #define xbt_dynar_foreach_ptr(_dynar,_cursor,_ptr) \ - for (_xbt_dynar_cursor_first(_dynar,&(_cursor)) ; \ - (_ptr = _cursor < _dynar->used ? xbt_dynar_get_ptr(_dynar,_cursor) : NULL) ; \ + 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 (_xbt_dynar_cursor_first(_dynar,&(_cursor)) ; \ - (_ptr = _cursor < _dynar->used ? (decltype(_ptr)) xbt_dynar_get_ptr(_dynar,_cursor) : NULL) ; \ + for ((_cursor) = 0 ; \ + (_ptr = _cursor < _dynar->used ? (decltype(_ptr)) xbt_dynar_get_ptr(_dynar,_cursor) : NULL) ; \ (_cursor)++ ) #endif /** @} */