Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1db97982d1c1f66bfcb9fa994aafaad880faabcb
[simgrid.git] / src / xbt / setset_private.h
1 #include "xbt/dict.h"
2 #include "xbt/dynar.h"
3 #include "xbt/setset.h"
4 #include "xbt/fifo.h"
5
6 #define BITS_INT (8 * sizeof(int))
7
8 typedef struct s_xbt_setset_elm {
9   XBT_SETSET_HEADERS;
10 } s_xbt_setset_elm_t, *xbt_setset_elm_t;
11
12 typedef union u_xbt_setset_elm_entry {
13   /* Information when the entry is being used */
14   struct {
15     unsigned int refcount;    
16     xbt_setset_elm_t obj;
17   } info;
18   /* Information when the entry is free */
19   struct {
20     unsigned long next;
21   } free;
22 } u_xbt_setset_elm_entry_t, *xbt_setset_elm_entry_t;
23
24 typedef struct s_xbt_setset_set {
25   xbt_setset_t setset;         /* setset that contains this set */
26   unsigned int elmcount;       /* number of elements */
27   unsigned int size;           /* in integers */
28   unsigned int *bitmap;        /* the bit array */
29 } s_xbt_setset_set_t;
30
31 typedef struct s_xbt_setset {
32   xbt_dynar_t elm_array;    /* of s_xbt_setset_elm_entry_t, to find elements by index */
33   xbt_fifo_t sets;         /* of s_xbt_setset_set_t, memberships in actual sets of setset */
34 } s_xbt_setset_t;
35
36 typedef struct s_xbt_setset_cursor {
37   int idx;       /* Actual postition of the cursor (bit number) */
38   xbt_setset_set_t set;   /* The set associated to the cursor */
39 } s_xbt_setset_cursor_t;
40
41 /* Some internal functions */
42
43 /* Add an object to the setset, this will calculate its index */
44 xbt_setset_elm_entry_t _xbt_setset_elm_add(xbt_setset_t setset, void *obj);
45
46 /* Remove from the setset the object stored at idx */
47 void _xbt_setset_elm_remove(xbt_setset_t setset, unsigned long idx);
48
49 /* Increase the refcount of an element */
50 void _xbt_setset_elm_use(xbt_setset_t setset, unsigned long idx);
51
52 /* Get the object associated to a given index */
53 void *_xbt_setset_idx_to_obj(xbt_setset_t setset, unsigned long idx);
54
55 /* Check if the nth bit of an integer is set or not*/
56 unsigned int _is_bit_set(unsigned int bit, unsigned int integer);
57
58 /* Set the nth bit of an array of integers */
59 void _set_bit(unsigned int bit, unsigned int *bitmap);
60
61 /* Unset the nth bit of an array of integers */
62 void _unset_bit(unsigned int bit, unsigned int *bitmap);
63
64
65
66
67
68
69