Sets of bits.
More...
#include <bit_field.h>
#include <stdint.h>
#include <malloc_extras.h>
#include "../common/constants.h"
#include <debug.h>
Go to the source code of this file.
|
bool | bit_set_clear (bit_set_t *b) |
| Empty a bitset entirely.
|
|
static bool | bit_set_init (bit_set_t *b, unsigned int length) |
| Create a new bitset.
|
|
static void | bit_set_delete (bit_set_t *b) |
| Destroy a bitset.
|
|
static bool | bit_set_add (bit_set_t *b, unsigned int i) |
| Add an element to a bitset.
|
|
static bool | bit_set_contains (bit_set_t *b, unsigned int i) |
| Test if an element is in a bitset.
|
|
static bool | bit_set_remove (bit_set_t *b, unsigned int i) |
| Remove an element from a bitset.
|
|
static void | print_bit_field_entry_v2 (uint32_t e, int offset) |
| This function prints out an individual word of a bit_field, as a sequence of ones and zeros.
|
|
void | print_bit_field_bits_v2 (bit_field_t b, size_t s) |
| This function prints out an entire bit_field, as a sequence of ones and zeros.
|
|
void | print_bit_set_bits (bit_field_t b, int s) |
| This function prints out an entire bit_field, as a sequence of ones and zeros.
|
|
void | print_bit_set (bit_set_t b) |
| prints a bit set
|
|
Sets of bits.
Definition in file bit_set.h.
◆ bit_set_t
wrapper over bitfield
Definition at line 33 of file bit_set.h.
Data Fields |
unsigned int |
count |
Keep track of members. |
unsigned int |
n_words |
Number of words in _data. |
unsigned int |
n_elements |
Number of elements which may be in the set. |
◆ bit_set_clear()
Empty a bitset entirely.
- Parameters
-
[in] | b | the bit set to clear bits |
- Returns
- bool saying successfully cleared bit field
Definition at line 50 of file bit_set.h.
◆ bit_set_init()
static bool bit_set_init |
( |
bit_set_t * | b, |
|
|
unsigned int | length ) |
|
inlinestatic |
Create a new bitset.
- Parameters
-
[in] | b | the bitset to create |
[in] | length | the length of bits to make |
- Returns
- whether the bitset was created
Definition at line 65 of file bit_set.h.
◆ bit_set_delete()
Destroy a bitset.
- Parameters
-
[in] | b | the bitset to delete |
Definition at line 89 of file bit_set.h.
◆ bit_set_add()
static bool bit_set_add |
( |
bit_set_t * | b, |
|
|
unsigned int | i ) |
|
inlinestatic |
Add an element to a bitset.
- Parameters
-
[in] | b | the bitset to add to |
[in] | i | the bit to set / add |
- Returns
- whether the bit is added successfully
Definition at line 100 of file bit_set.h.
◆ bit_set_contains()
static bool bit_set_contains |
( |
bit_set_t * | b, |
|
|
unsigned int | i ) |
|
inlinestatic |
Test if an element is in a bitset.
- Parameters
-
[in] | b | the bitset to check |
[in] | i | the bit to check is set /added |
- Returns
- whether the bit is set/added in the bitfield
Definition at line 121 of file bit_set.h.
◆ bit_set_remove()
static bool bit_set_remove |
( |
bit_set_t * | b, |
|
|
unsigned int | i ) |
|
inlinestatic |
Remove an element from a bitset.
- Parameters
-
[in] | b | the bitset to remove/unset the bit from |
[in] | i | the bit to unset |
- Returns
- whether unset succeeded
Definition at line 136 of file bit_set.h.
◆ print_bit_field_entry_v2()
static void print_bit_field_entry_v2 |
( |
uint32_t | e, |
|
|
int | offset ) |
|
inlinestatic |
This function prints out an individual word of a bit_field, as a sequence of ones and zeros.
- Parameters
-
[in] | e | The word of a bit_field to be printed. |
[in] | offset | the offset in id |
Definition at line 156 of file bit_set.h.
◆ print_bit_field_bits_v2()
This function prints out an entire bit_field, as a sequence of ones and zeros.
- Parameters
-
[in] | b | The sequence of words representing a bit_field. |
[in] | s | The size of the bit_field. |
Definition at line 167 of file bit_set.h.
◆ print_bit_set_bits()
This function prints out an entire bit_field, as a sequence of ones and zeros.
- Parameters
-
[in] | b | The sequence of words representing a bit_field. |
[in] | s | The size of the bit_field. |
Definition at line 177 of file bit_set.h.
◆ print_bit_set()
prints a bit set
- Parameters
-
Definition at line 185 of file bit_set.h.