1 /* Copyright (c) 2010, 2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
11 typedef struct s_xbt_setset *xbt_setset_t;
13 typedef struct s_xbt_setset_set *xbt_setset_set_t;
15 typedef struct s_xbt_setset_cursor *xbt_setset_cursor_t;
17 #define XBT_SETSET_HEADERS \
21 xbt_setset_t xbt_setset_new(unsigned int size);
24 void xbt_setset_destroy(xbt_setset_t setset);
26 /* Add an object to the setset, this will calculate its ID */
27 void xbt_setset_elm_add(xbt_setset_t setset, void *obj);
29 /* Remove an object from the setset */
30 void xbt_setset_elm_remove(xbt_setset_t setset, void *obj);
32 /* Create a new set in the setset */
33 xbt_setset_set_t xbt_setset_new_set(xbt_setset_t setset);
35 /* Destroy a set in the setset */
36 void xbt_setset_destroy_set(xbt_setset_set_t);
38 /* Insert an element into a set */
39 void xbt_setset_set_insert(xbt_setset_set_t set, void *obj);
41 /* Remove an element from a set */
42 void xbt_setset_set_remove(xbt_setset_set_t set, void *obj);
44 /* Remove all the elements of a set */
45 void xbt_setset_set_reset(xbt_setset_set_t set);
47 /* Select one element of a set */
48 void *xbt_setset_set_choose(xbt_setset_set_t set);
50 /* Extract one element of a set */
51 void *xbt_setset_set_extract(xbt_setset_set_t set);
53 /* Test if an element belongs to a set */
54 int xbt_setset_set_belongs(xbt_setset_set_t set, void *obj);
56 /* Get the number of elements in a set */
57 int xbt_setset_set_size(xbt_setset_set_t set);
59 /* Add all elements of set2 to set1 */
60 void xbt_setset_add(xbt_setset_set_t set1, xbt_setset_set_t set2);
62 /* Substract all elements of set2 from set1 */
63 void xbt_setset_substract(xbt_setset_set_t set1, xbt_setset_set_t set2);
65 /* Intersect set1 and set2 storing the result in set1 */
66 void xbt_setset_intersect(xbt_setset_set_t set1, xbt_setset_set_t set2);
68 /* Get the cursor to point to the first element of a set */
69 void xbt_setset_cursor_first(xbt_setset_set_t set,
70 xbt_setset_cursor_t * cursor);
72 /* Get the data pointed by a cursor */
73 int xbt_setset_cursor_get_data(xbt_setset_cursor_t cursor, void **data);
75 /* Advance a cursor to the next element */
76 void xbt_setset_cursor_next(xbt_setset_cursor_t cursor);
79 #define xbt_setset_foreach(set, cursor, data) \
80 for(xbt_setset_cursor_first(set, &cursor); \
81 xbt_setset_cursor_get_data(cursor, (void **)&data); \
82 xbt_setset_cursor_next(cursor))