3 /* xbt/set.h -- api to a generic dictionary */
5 /* Copyright (c) 2004 Martin Quinson. All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
13 #include "xbt/misc.h" /* BEGIN_DECL */
17 /*####[ Type definition ]####################################################*/
18 typedef struct xbt_set_ *xbt_set_t;
19 typedef struct xbt_set_elm_ {
22 unsigned int name_len;
23 } s_xbt_set_elm_t,*xbt_set_elm_t;
25 /*####[ Functions ]##########################################################*/
27 xbt_set_t xbt_set_new (void);
28 void xbt_set_free(xbt_set_t *set);
31 void xbt_set_add (xbt_set_t set,
33 void_f_pvoid_t *free_func);
35 /*----[ xbt_set_retrieve ]-------------------------------------------------*/
36 /* Search the given #key#. data=NULL when not found. */
37 /*---------------------------------------------------------------------------*/
38 xbt_error_t xbt_set_get_by_name (xbt_set_t set,
40 /* OUT */xbt_set_elm_t *dst);
41 xbt_error_t xbt_set_get_by_name_ext(xbt_set_t set,
44 /* OUT */xbt_set_elm_t *dst);
45 xbt_error_t xbt_set_get_by_id (xbt_set_t set,
47 /* OUT */xbt_set_elm_t *dst);
49 /*####[ Cache cursor functions ]#############################################*/
50 /* To traverse (simple) caches */
51 /* Don't add or remove entries to the cache while traversing !!! */
52 /*###########################################################################*/
53 typedef struct xbt_set_cursor_ *xbt_set_cursor_t;
55 void xbt_set_cursor_first (xbt_set_t set,
56 xbt_set_cursor_t *cursor);
57 void xbt_set_cursor_step (xbt_set_cursor_t cursor);
58 int xbt_set_cursor_get_or_free (xbt_set_cursor_t *cursor,
61 #define xbt_set_foreach(set,cursor,elm) \
62 for ((cursor) = NULL, xbt_set_cursor_first((set),&(cursor)) ; \
63 xbt_set_cursor_get_or_free(&(cursor),(xbt_set_elm_t*)&(elm)); \
64 xbt_set_cursor_step(cursor) )
68 #endif /* _XBT_SET_H */