3 /* xbt/set.h -- api to a generic dictionary */
5 /* Authors: Martin Quinson */
6 /* Copyright (C) 2004 the OURAGAN project. */
8 /* This program is free software; you can redistribute it and/or modify it
9 under the terms of the license (GNU LGPL) which comes with this package. */
15 #include "xbt/misc.h" /* BEGIN_DECL */
19 /*####[ Type definition ]####################################################*/
20 typedef struct xbt_set_ *xbt_set_t;
21 typedef struct xbt_set_elm_ {
24 unsigned int name_len;
25 } s_xbt_set_elm_t,*xbt_set_elm_t;
27 /*####[ Functions ]##########################################################*/
29 xbt_set_t xbt_set_new (void);
30 void xbt_set_free(xbt_set_t *set);
33 void xbt_set_add (xbt_set_t set,
35 void_f_pvoid_t *free_func);
37 /*----[ xbt_set_retrieve ]-------------------------------------------------*/
38 /* Search the given #key#. data=NULL when not found. */
39 /*---------------------------------------------------------------------------*/
40 xbt_error_t xbt_set_get_by_name (xbt_set_t set,
42 /* OUT */xbt_set_elm_t *dst);
43 xbt_error_t xbt_set_get_by_name_ext(xbt_set_t set,
46 /* OUT */xbt_set_elm_t *dst);
47 xbt_error_t xbt_set_get_by_id (xbt_set_t set,
49 /* OUT */xbt_set_elm_t *dst);
51 /*####[ Cache cursor functions ]#############################################*/
52 /* To traverse (simple) caches */
53 /* Don't add or remove entries to the cache while traversing !!! */
54 /*###########################################################################*/
55 typedef struct xbt_set_cursor_ *xbt_set_cursor_t;
57 void xbt_set_cursor_first (xbt_set_t set,
58 xbt_set_cursor_t *cursor);
59 void xbt_set_cursor_step (xbt_set_cursor_t cursor);
60 int xbt_set_cursor_get_or_free (xbt_set_cursor_t *cursor,
63 #define xbt_set_foreach(set,cursor,elm) \
64 for ((cursor) = NULL, xbt_set_cursor_first((set),&(cursor)) ; \
65 xbt_set_cursor_get_or_free(&(cursor),(xbt_set_elm_t*)&(elm)); \
66 xbt_set_cursor_step(cursor) )
70 #endif /* _XBT_SET_H */