Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e5e461800b347231c3fa95cf4e9c3f971a692204
[simgrid.git] / include / xbt / setset.h
1 #ifndef _XBT_SETSET_H
2 #define _XBT_SETSET_H
3 #include "xbt/misc.h"
4
5 typedef struct s_xbt_setset *xbt_setset_t;
6
7 typedef struct s_xbt_setset_set *xbt_setset_set_t;
8
9 typedef struct s_xbt_setset_cursor *xbt_setset_cursor_t;
10
11 #define XBT_SETSET_HEADERS \
12   unsigned long ID
13
14 /* Constructor */
15 xbt_setset_t xbt_setset_new(unsigned int size);
16
17 /* Destructor */
18 void xbt_setset_destroy(xbt_setset_t setset);
19
20 /* Create a new set in the setset */
21 xbt_setset_set_t xbt_setset_new_set(xbt_setset_t setset);
22
23 /* Destroy a set in the setset */
24 void xbt_setset_destroy_set(xbt_setset_set_t);
25
26 /* Insert an element into a set */
27 void xbt_setset_set_insert(xbt_setset_set_t set, void* obj);
28
29 /* Remove an element from a set */
30 void xbt_setset_set_remove(xbt_setset_set_t set, void* obj);
31
32 /* Remove all the elements of a set */
33 void xbt_setset_set_reset(xbt_setset_set_t set);
34
35 /* Select one element of a set */
36 void *xbt_setset_set_choose(xbt_setset_set_t set);
37
38 /* Extract one element of a set */
39 void *xbt_setset_set_extract(xbt_setset_set_t set);
40
41 /* Test if an element belongs to a set */
42 int xbt_setset_set_belongs(xbt_setset_set_t set, void* obj);
43
44 /* Get the number of elements in a set */
45 int xbt_setset_set_size(xbt_setset_set_t set);
46
47 /* Add all elements of set2 to set1 */
48 void xbt_setset_add(xbt_setset_set_t set1, xbt_setset_set_t set2);
49
50 /* Substract all elements of set2 from set1 */
51 void xbt_setset_substract(xbt_setset_set_t set1, xbt_setset_set_t set2);
52
53 /* Intersect set1 and set2 storing the result in set1 */
54 void xbt_setset_intersect(xbt_setset_set_t set1, xbt_setset_set_t set2);
55
56 /* Get the cursor to point to the first element of a set */
57 void xbt_setset_cursor_first(xbt_setset_set_t set, xbt_setset_cursor_t *cursor);
58
59 /* Get the data pointed by a cursor */
60 int xbt_setset_cursor_get_data(xbt_setset_cursor_t cursor, void **data);
61
62 /* Advance a cursor to the next element */
63 void xbt_setset_cursor_next(xbt_setset_cursor_t cursor);
64
65
66 #define xbt_setset_foreach(set, cursor, data) \
67           for(xbt_setset_cursor_first(set, &cursor);  \
68               xbt_setset_cursor_get_data(cursor, (void **)&data); \
69               xbt_setset_cursor_next(cursor))  
70
71 #endif