Raphael Manfredi
#include "common.h"
Go to the source code of this file.
Defines | |
| #define | BIT_ARRAY_BITSIZE (CHAR_BIT * sizeof(bit_array_t)) |
| #define | BIT_ARRAY_BITMASK (BIT_ARRAY_BITSIZE - 1) |
| #define | BIT_ARRAY_WORD(base, i) base[(i) >> BIT_ARRAY_BITSHIFT] |
| #define | BIT_ARRAY_BIT(base, i) (1UL << ((i) & BIT_ARRAY_BITMASK)) |
| #define | BIT_ARRAY_SIZE(n) |
| Use the macro BIT_ARRAY_SIZE for allocating a properly sized bit array for "n" bits. | |
| #define | BIT_ARRAY_BYTE_SIZE(n) (BIT_ARRAY_SIZE(n) * sizeof (bit_array_t)) |
| Use the macro BIT_ARRAY_BYTE_SIZE for dynamic allocation. | |
Typedefs | |
| typedef unsigned long | bit_array_t |
Functions | |
| bit_array_t * | bit_array_realloc (bit_array_t *base, size_t n) |
| Re-allocates "base" so that it can hold at least "n" bits. | |
| void | bit_array_set (bit_array_t *base, size_t i) |
| Sets bit number "i" of the bit array "base". | |
| void | bit_array_clear (bit_array_t *base, size_t i) |
| Sets bit number "i" of the bit array "base". | |
| gboolean | bit_array_flip (bit_array_t *base, size_t i) |
| Flips bit number "i" of the bit array "base". | |
| gboolean | bit_array_get (const bit_array_t *base, size_t i) |
| Retrieves bit number "i" of the bit array "base". | |
| void | bit_array_clear_range (bit_array_t *base, size_t from, size_t to) |
| Clears all bits starting at "from" up to "to" inclusive. | |
| void | bit_array_set_range (bit_array_t *base, size_t from, size_t to) |
| Sets all bits starting at "from" up to "to" inclusive. | |
| size_t | bit_array_first_clear (const bit_array_t *base, size_t from, size_t to) |
| Peforms a linear scan for the first unset bit of the given bit array. | |
|
|
|
|
|
|
|
|
|
|
|
Use the macro BIT_ARRAY_BYTE_SIZE for dynamic allocation. Example: bit_array_t *bits = malloc(BIT_ARRAY_BYTE_SIZE(num_bits)); |
|
|
Value: ((n) / (CHAR_BIT * sizeof(bit_array_t)) + \ ((n) % (CHAR_BIT * sizeof(bit_array_t)) ? 1 : 0)) Example: static bit_array_t ba[BIT_ARRAY_SIZE(100)]; |
|
|
|
|
|
|
|
||||||||||||
|
Sets bit number "i" of the bit array "base".
|
|
||||||||||||||||
|
Clears all bits starting at "from" up to "to" inclusive.
|
|
||||||||||||||||
|
Peforms a linear scan for the first unset bit of the given bit array.
|
|
||||||||||||
|
Flips bit number "i" of the bit array "base".
|
|
||||||||||||
|
Retrieves bit number "i" of the bit array "base".
|
|
||||||||||||
|
Re-allocates "base" so that it can hold at least "n" bits.
|
|
||||||||||||
|
Sets bit number "i" of the bit array "base".
|
|
||||||||||||||||
|
Sets all bits starting at "from" up to "to" inclusive.
|
1.3.9.1