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. */
10 #include "xbt/setset.h"
13 #define BITS_INT (8 * sizeof(int))
15 typedef struct s_xbt_setset_elm {
17 } s_xbt_setset_elm_t, *xbt_setset_elm_t;
19 typedef union u_xbt_setset_elm_entry {
20 /* Information when the entry is being used */
24 /* Information when the entry is free */
28 } u_xbt_setset_elm_entry_t, *xbt_setset_elm_entry_t;
30 typedef struct s_xbt_setset_set {
31 xbt_setset_t setset; /* setset that contains this set */
32 unsigned int size; /* in integers */
33 unsigned int *bitmap; /* the bit array */
36 typedef struct s_xbt_setset {
37 xbt_dynar_t elm_array; /* of s_xbt_setset_elm_entry_t, to find elements by index */
38 xbt_fifo_t sets; /* of s_xbt_setset_set_t, memberships in actual sets of setset */
41 typedef struct s_xbt_setset_cursor {
42 int idx; /* Actual postition of the cursor (bit number) */
43 xbt_setset_set_t set; /* The set associated to the cursor */
44 } s_xbt_setset_cursor_t;
46 /* Some internal functions */
48 XBT_PRIVATE int bitcount(int);
50 /* Get the object associated to a given index */
51 XBT_PRIVATE void *_xbt_setset_idx_to_obj(xbt_setset_t setset, unsigned long idx);
53 /* Check if the nth bit of an integer is set or not*/
54 XBT_PRIVATE unsigned int _is_bit_set(unsigned int bit, unsigned int integer);
56 /* Set the nth bit of an array of integers */
57 XBT_PRIVATE void _set_bit(unsigned int bit, unsigned int *bitmap);
59 /* Unset the nth bit of an array of integers */
60 XBT_PRIVATE void _unset_bit(unsigned int bit, unsigned int *bitmap);