Skip to content

acl/core/bitset.h

#include "acl/core/bitset.h"

The functions that read and write bit sets.

bitset_description

class bitset_description

A bit set description holds the required information to ensure type and memory safety with the various bit set functions.

bitset_description::bitset_description

constexpr constexpr bitset_description()

Creates an invalid bit set description.

bitset_description::make_from_num_bits

template<uint64_t num_bits>
static constexpr bitset_description make_from_num_bits()

Creates a bit set description from a compile time known number of bits.

static bitset_description make_from_num_bits(uint32_t num_bits)

Creates a bit set description from a runtime known number of bits.

bitset_description::get_size

constexpr uint32_t get_size() const

Returns the number of 32 bit words used to represent the bitset. 1 == 32 bits, 2 == 64 bits, etc.

bitset_description::get_num_bits

constexpr uint32_t get_num_bits() const

Returns the number of bits contained within the bit set.

bitset_description::get_num_bytes

constexpr uint32_t get_num_bytes() const

Returns the number of bytes used by the bit set.

bitset_description::is_bit_index_valid

constexpr bool is_bit_index_valid(uint32_t index) const

Returns true if the index is valid within the bit set.

bitset_index_ref

struct bitset_index_ref

A bit set index reference is created from a bit set description and a bit index. It holds the bit set word offset as well as the bit mask required. This is useful if you sample multiple bit sets at the same index.

bitset_index_ref::bitset_index_ref

bitset_index_ref(bitset_description desc_, uint32_t bit_index)

Constructs a reference to the given bit in the bit sets of the given description.

bitset_index_ref::desc

bitset_description desc;

The description of the bit sets.

bitset_index_ref::offset

uint32_t offset;

The index of the 32 bit word that holds the bit.

bitset_index_ref::mask

uint32_t mask;

The mask of the bit in its word.

bitset_reset

void bitset_reset(uint32_t* bitset, bitset_description desc, bool value)

Resets the entire bit set to the provided value.

bitset_set

void bitset_set(uint32_t* bitset, bitset_description desc, uint32_t bit_index, bool value)
void bitset_set(uint32_t* bitset, const bitset_index_ref& ref, bool value)

Sets a specific bit to its desired value.

bitset_set_range

void bitset_set_range(
    uint32_t* bitset,
    bitset_description desc,
    uint32_t start_bit_index,
    uint32_t num_bits,
    bool value)

Sets a specified range of bits to a specified value.

bitset_test

bool bitset_test(const uint32_t* bitset, bitset_description desc, uint32_t bit_index)
bool bitset_test(const uint32_t* bitset, const bitset_index_ref& ref)

Returns the bit value as a specific index.

bitset_count_set_bits

uint32_t bitset_count_set_bits(const uint32_t* bitset, bitset_description desc)

Counts the total number of set (true) bits within the bit set.

bitset_and_not

void bitset_and_not(
    uint32_t* bitset_result,
    const uint32_t* bitset_not_value,
    const uint32_t* bitset_and_value,
    bitset_description desc)

Performs the operation: result = ~not_value & and_value Bit sets must have the same description Bit sets can alias