Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge 'master' into mc
[simgrid.git] / src / xbt / setset_private.h
1 /* Copyright (c) 2010, 2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "xbt/dict.h"
8 #include "xbt/dynar.h"
9 #include "xbt/setset.h"
10 #include "xbt/fifo.h"
11
12 #define BITS_INT (8 * sizeof(int))
13
14 typedef struct s_xbt_setset_elm {
15   XBT_SETSET_HEADERS;
16 } s_xbt_setset_elm_t, *xbt_setset_elm_t;
17
18 typedef union u_xbt_setset_elm_entry {
19   /* Information when the entry is being used */
20   struct {
21     xbt_setset_elm_t obj;
22   } info;
23   /* Information when the entry is free */
24   struct {
25     unsigned long next;
26   } free;
27 } u_xbt_setset_elm_entry_t, *xbt_setset_elm_entry_t;
28
29 typedef struct s_xbt_setset_set {
30   xbt_setset_t setset;          /* setset that contains this set */
31   unsigned int size;            /* in integers */
32   unsigned int *bitmap;         /* the bit array */
33 } s_xbt_setset_set_t;
34
35 typedef struct s_xbt_setset {
36   xbt_dynar_t elm_array;        /* of s_xbt_setset_elm_entry_t, to find elements by index */
37   xbt_fifo_t sets;              /* of s_xbt_setset_set_t, memberships in actual sets of setset */
38 } s_xbt_setset_t;
39
40 typedef struct s_xbt_setset_cursor {
41   int idx;                      /* Actual postition of the cursor (bit number) */
42   xbt_setset_set_t set;         /* The set associated to the cursor */
43 } s_xbt_setset_cursor_t;
44
45 /* Some internal functions */
46
47 int bitcount(int);
48
49 /* Get the object associated to a given index */
50 void *_xbt_setset_idx_to_obj(xbt_setset_t setset, unsigned long idx);
51
52 /* Check if the nth bit of an integer is set or not*/
53 unsigned int _is_bit_set(unsigned int bit, unsigned int integer);
54
55 /* Set the nth bit of an array of integers */
56 void _set_bit(unsigned int bit, unsigned int *bitmap);
57
58 /* Unset the nth bit of an array of integers */
59 void _unset_bit(unsigned int bit, unsigned int *bitmap);