Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
I blame someone else for this
[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 /* Add an object to the setset, this will calculate its ID */
21 void xbt_setset_elm_add(xbt_setset_t setset, void *obj);
22
23 /* Remove an object from the setset */
24 void xbt_setset_elm_remove(xbt_setset_t setset, void *obj);
25
26 /* Create a new set in the setset */
27 xbt_setset_set_t xbt_setset_new_set(xbt_setset_t setset);
28
29 /* Destroy a set in the setset */
30 void xbt_setset_destroy_set(xbt_setset_set_t);
31
32 /* Insert an element into a set */
33 void xbt_setset_set_insert(xbt_setset_set_t set, void *obj);
34
35 /* Remove an element from a set */
36 void xbt_setset_set_remove(xbt_setset_set_t set, void *obj);
37
38 /* Remove all the elements of a set */
39 void xbt_setset_set_reset(xbt_setset_set_t set);
40
41 /* Select one element of a set */
42 void *xbt_setset_set_choose(xbt_setset_set_t set);
43
44 /* Extract one element of a set */
45 void *xbt_setset_set_extract(xbt_setset_set_t set);
46
47 /* Test if an element belongs to a set */
48 int xbt_setset_set_belongs(xbt_setset_set_t set, void *obj);
49
50 /* Get the number of elements in a set */
51 int xbt_setset_set_size(xbt_setset_set_t set);
52
53 /* Add all elements of set2 to set1 */
54 void xbt_setset_add(xbt_setset_set_t set1, xbt_setset_set_t set2);
55
56 /* Substract all elements of set2 from set1 */
57 void xbt_setset_substract(xbt_setset_set_t set1, xbt_setset_set_t set2);
58
59 /* Intersect set1 and set2 storing the result in set1 */
60 void xbt_setset_intersect(xbt_setset_set_t set1, xbt_setset_set_t set2);
61
62 /* Get the cursor to point to the first element of a set */
63 void xbt_setset_cursor_first(xbt_setset_set_t set,
64                              xbt_setset_cursor_t * cursor);
65
66 /* Get the data pointed by a cursor */
67 int xbt_setset_cursor_get_data(xbt_setset_cursor_t cursor, void **data);
68
69 /* Advance a cursor to the next element */
70 void xbt_setset_cursor_next(xbt_setset_cursor_t cursor);
71
72
73 #define xbt_setset_foreach(set, cursor, data) \
74           for(xbt_setset_cursor_first(set, &cursor);  \
75               xbt_setset_cursor_get_data(cursor, (void **)&data); \
76               xbt_setset_cursor_next(cursor))
77
78 #endif