3 #include "xbt/setset.h"
6 #define BITS_INT (8 * sizeof(int))
8 typedef struct s_xbt_setset_elm {
10 } s_xbt_setset_elm_t, *xbt_setset_elm_t;
12 typedef union u_xbt_setset_elm_entry {
13 /* Information when the entry is being used */
15 unsigned int refcount;
18 /* Information when the entry is free */
22 } u_xbt_setset_elm_entry_t, *xbt_setset_elm_entry_t;
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 */
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 */
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;
41 /* Some internal functions */
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);
46 /* Remove from the setset the object stored at idx */
47 void _xbt_setset_elm_remove(xbt_setset_t setset, unsigned long idx);
49 /* Increase the refcount of an element */
50 void _xbt_setset_elm_use(xbt_setset_t setset, unsigned long idx);
52 /* Get the object associated to a given index */
53 void *_xbt_setset_idx_to_obj(xbt_setset_t setset, unsigned long idx);
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);
58 /* Set the nth bit of an array of integers */
59 void _set_bit(unsigned int bit, unsigned int *bitmap);
61 /* Unset the nth bit of an array of integers */
62 void _unset_bit(unsigned int bit, unsigned int *bitmap);