67#include "private/private_bitset.h"
105#define CCC_bitset_block_count(bit_capacity) \
106 CCC_private_bitset_block_count(bit_capacity)
112#define CCC_bitset_block_bytes(bit_capacity) \
113 CCC_private_bitset_block_bytes(bit_capacity)
117#define CCC_bitset_default() CCC_private_bitset_default()
143#define CCC_bitset_with_storage( \
144 count, compound_literal_array, optional_storage_specifier... \
146 CCC_private_bitset_with_storage( \
147 count, compound_literal_array, optional_storage_specifier \
186#define CCC_bitset_from( \
188 start_string_index, \
192 optional_capacity... \
194 CCC_private_bitset_from( \
196 start_string_index, \
235#define CCC_bitset_with_capacity(allocator, capacity, optional_count...) \
236 CCC_private_bitset_with_capacity(allocator, capacity, optional_count)
276#define CCC_bitset_storage_for( \
277 bit_compound_literal_array, optional_storage_specifier... \
279 CCC_private_bitset_storage_for( \
280 bit_compound_literal_array, optional_storage_specifier \
316#define CCC_bitset_for(cap, count, bitblock_pointer...) \
317 CCC_private_bitset_for(cap, count, bitblock_pointer)
431 size_t range_start_index,
432 size_t range_bit_count,
462 CCC_Bitset *bitset,
size_t range_start_index,
size_t range_bit_count
491 CCC_Bitset *bitset,
size_t range_start_index,
size_t range_bit_count
514 CCC_Bitset const *bitset,
size_t range_start_index,
size_t range_bit_count
531 CCC_Bitset const *bitset,
size_t range_start_index,
size_t range_bit_count
549 CCC_Bitset const *bitset,
size_t range_start_index,
size_t range_bit_count
568 CCC_Bitset const *bitset,
size_t range_start_index,
size_t range_bit_count
593 size_t range_start_index,
594 size_t range_bit_count,
614 CCC_Bitset const *bitset,
size_t range_start_index,
size_t range_bit_count
639 size_t range_start_index,
640 size_t range_bit_count,
687 size_t range_start_index,
688 size_t range_bit_count,
710 CCC_Bitset const *bitset,
size_t range_start_index,
size_t range_bit_count
738 size_t range_start_index,
739 size_t range_bit_count,
921 CCC_Bitset const *bitset,
size_t range_start_index,
size_t range_bit_count
973#ifdef BITSET_USING_NAMESPACE_CCC
977# define BITSET_BLOCK_BITS CCC_BITSET_BLOCK_BITS
978# define bitset_block_count(arguments...) CCC_bitset_block_count(arguments)
979# define bitset_block_bytes(arguments...) CCC_bitset_block_bytes(arguments)
980# define bitset_storage_for(arguments...) CCC_bitset_storage_for(arguments)
981# define bitset_default(arguments...) CCC_bitset_default(arguments)
982# define bitset_for(arguments...) CCC_bitset_for(arguments)
983# define bitset_from(arguments...) CCC_bitset_from(arguments)
984# define bitset_with_capacity(arguments...) \
985 CCC_bitset_with_capacity(arguments)
986# define bitset_with_storage(arguments...) CCC_bitset_with_storage(arguments)
987# define bitset_copy(arguments...) CCC_bitset_copy(arguments)
988# define bitset_reserve(arguments...) CCC_bitset_reserve(arguments)
989# define bitset_test(arguments...) CCC_bitset_test(arguments)
990# define bitset_set(arguments...) CCC_bitset_set(arguments)
991# define bitset_set_all(arguments...) CCC_bitset_set_all(arguments)
992# define bitset_set_range(arguments...) CCC_bitset_set_range(arguments)
993# define bitset_reset(arguments...) CCC_bitset_reset(arguments)
994# define bitset_reset_all(arguments...) CCC_bitset_reset_all(arguments)
995# define bitset_reset_range(arguments...) CCC_bitset_reset_range(arguments)
996# define bitset_flip(arguments...) CCC_bitset_flip(arguments)
997# define bitset_flip_all(arguments...) CCC_bitset_flip_all(arguments)
998# define bitset_flip_range(arguments...) CCC_bitset_flip_range(arguments)
999# define bitset_any(arguments...) CCC_bitset_any(arguments)
1000# define bitset_any_range(arguments...) CCC_bitset_any_range(arguments)
1001# define bitset_none(arguments...) CCC_bitset_none(arguments)
1002# define bitset_none_range(arguments...) CCC_bitset_none_range(arguments)
1003# define bitset_all(arguments...) CCC_bitset_all(arguments)
1004# define bitset_all_range(arguments...) CCC_bitset_all_range(arguments)
1005# define bitset_first_trailing_one(arguments...) \
1006 CCC_bitset_first_trailing_one(arguments)
1007# define bitset_first_trailing_one_range(arguments...) \
1008 CCC_bitset_first_trailing_one_range(arguments)
1009# define bitset_first_trailing_ones(arguments...) \
1010 CCC_bitset_first_trailing_ones(arguments)
1011# define bitset_first_trailing_ones_range(arguments...) \
1012 CCC_bitset_first_trailing_ones_range(arguments)
1013# define bitset_first_trailing_zero(arguments...) \
1014 CCC_bitset_first_trailing_zero(arguments)
1015# define bitset_first_trailing_zero_range(arguments...) \
1016 CCC_bitset_first_trailing_zero_range(arguments)
1017# define bitset_first_trailing_zeros(arguments...) \
1018 CCC_bitset_first_trailing_zeros(arguments)
1019# define bitset_first_trailing_zeros_range(arguments...) \
1020 CCC_bitset_first_trailing_zeros_range(arguments)
1021# define bitset_first_leading_one(arguments...) \
1022 CCC_bitset_first_leading_one(arguments)
1023# define bitset_first_leading_one_range(arguments...) \
1024 CCC_bitset_first_leading_one_range(arguments)
1025# define bitset_first_leading_ones(arguments...) \
1026 CCC_bitset_first_leading_ones(arguments)
1027# define bitset_first_leading_ones_range(arguments...) \
1028 CCC_bitset_first_leading_ones_range(arguments)
1029# define bitset_first_leading_zero(arguments...) \
1030 CCC_bitset_first_leading_zero(arguments)
1031# define bitset_first_leading_zero_range(arguments...) \
1032 CCC_bitset_first_leading_zero_range(arguments)
1033# define bitset_first_leading_zeros(arguments...) \
1034 CCC_bitset_first_leading_zeros(arguments)
1035# define bitset_first_leading_zeros_range(arguments...) \
1036 CCC_bitset_first_leading_zeros_range(arguments)
1037# define bitset_or(arguments...) CCC_bitset_or(arguments)
1038# define bitset_and(arguments...) CCC_bitset_and(arguments)
1039# define bitset_xor(arguments...) CCC_bitset_xor(arguments)
1040# define bitset_shift_left(arguments...) CCC_bitset_shift_left(arguments)
1041# define bitset_shift_right(arguments...) CCC_bitset_shift_right(arguments)
1042# define bitset_is_equal(arguments...) CCC_bitset_is_equal(arguments)
1043# define bitset_is_proper_subset(arguments...) \
1044 CCC_bitset_is_proper_subset(arguments)
1045# define bitset_is_subset(arguments...) CCC_bitset_is_subset(arguments)
1046# define bitset_data(arguments...) CCC_bitset_data(arguments)
1047# define bitset_capacity(arguments...) CCC_bitset_capacity(arguments)
1048# define bitset_blocks_capacity(arguments...) \
1049 CCC_bitset_blocks_capacity(arguments)
1050# define bitset_count(arguments...) CCC_bitset_count(arguments)
1051# define bitset_blocks_count(arguments...) CCC_bitset_blocks_count(arguments)
1052# define bitset_is_empty(arguments...) CCC_bitset_is_empty(arguments)
1053# define bitset_popcount(arguments...) CCC_bitset_popcount(arguments)
1054# define bitset_popcount_range(arguments...) \
1055 CCC_bitset_popcount_range(arguments)
1056# define bitset_clear(arguments...) CCC_bitset_clear(arguments)
1057# define bitset_clear_and_free(arguments...) \
1058 CCC_bitset_clear_and_free(arguments)
1059# define bitset_push_back(arguments...) CCC_bitset_push_back(arguments)
1060# define bitset_pop_back(arguments...) CCC_bitset_pop_back(arguments)
CCC_Result CCC_bitset_clear(CCC_Bitset *bitset)
Clears the bit set by setting the size to 0 and all bits to 0. The underlying memory capacity remains...
CCC_Tribool CCC_bitset_reset(CCC_Bitset *bitset, size_t index)
Set the bit at valid index index to boolean value b (true or false).
CCC_Result CCC_bitset_copy(CCC_Bitset *destination, CCC_Bitset const *source, CCC_Allocator const *allocator)
Copy the bit set at source to destination.
CCC_Tribool CCC_bitset_is_equal(CCC_Bitset const *left, CCC_Bitset const *right)
Checks two bit sets of the same size (not capacity) for equality.
CCC_Tribool CCC_bitset_test(CCC_Bitset const *bitset, size_t index)
Test the bit at index index for boolean status (CCC_TRUE or CCC_FALSE).
CCC_Count CCC_bitset_first_leading_zero(CCC_Bitset const *bitset)
Return the index of the first leading bit set to 0 in the set, starting from the Most Significant Bit...
CCC_Result CCC_bitset_reset_all(CCC_Bitset *bitset)
Set all the bits to CCC_FALSE.
CCC_Result CCC_bitset_xor(CCC_Bitset *destination, CCC_Bitset const *source)
Bitwise XOR destination set with source set.
CCC_Result CCC_bitset_flip_all(CCC_Bitset *bitset)
Toggle all of the bits to their opposing boolean value.
CCC_Count CCC_bitset_count(CCC_Bitset const *bitset)
Return total number of bits actively tracked by the user and set.
CCC_Tribool CCC_bitset_is_proper_subset(CCC_Bitset const *subset, CCC_Bitset const *set)
Return CCC_TRUE if subset is a proper subset of set (subset ⊂ set).
CCC_Count CCC_bitset_blocks_count(CCC_Bitset const *bitset)
Return number of CCC_bitblocks used by the bit set for size bits.
CCC_Count CCC_bitset_first_leading_zeros(CCC_Bitset const *bitset, size_t zeros_count)
Returns the index of the start of the first leading number of contiguous 0 bits.
CCC_Count CCC_bitset_popcount(CCC_Bitset const *bitset)
Return the number of bits set to CCC_TRUE. O(n).
CCC_Count CCC_bitset_first_leading_one_range(CCC_Bitset const *bitset, size_t index, size_t count)
Return the index of the first leading bit set to 1 in the range [i, index + count).
CCC_Tribool CCC_bitset_pop_back(CCC_Bitset *bitset)
Remove the Most Significant Bit from the set.
CCC_Result CCC_bitset_and(CCC_Bitset *destination, CCC_Bitset const *source)
Bitwise AND destination set with source set.
CCC_Count CCC_bitset_first_trailing_zero(CCC_Bitset const *bitset)
Return the index of the first bit set to 0 in the set.
@ CCC_BITSET_BLOCK_BITS
The number of bits in a block of the bit set.
Definition: bitset.h:98
CCC_Tribool CCC_bitset_any(CCC_Bitset const *bitset)
Return true if any bits in set are 1.
CCC_Tribool CCC_bitset_all_range(CCC_Bitset const *bitset, size_t range_start_index, size_t range_bit_count)
Return true if all bits are set to 1 in the range [index, index + count).
CCC_Tribool CCC_bitset_all(CCC_Bitset const *bitset)
Return true if all bits in set are 1.
CCC_Tribool CCC_bitset_flip(CCC_Bitset *bitset, size_t index)
Toggle the bit at index i.
CCC_Count CCC_bitset_first_leading_one(CCC_Bitset const *bitset)
Return the index of the first leading bit set to 1 in the set, starting from the Most Significant Bit...
CCC_Count CCC_bitset_first_trailing_one(CCC_Bitset const *bitset)
Return the index of the first trailing bit set to 1 in the set.
CCC_Result CCC_bitset_flip_range(CCC_Bitset *bitset, size_t range_start_index, size_t range_bit_count)
Flip all the bits in the range, starting at the Least Significant Bit in range and ending at the Most...
CCC_Result CCC_bitset_clear_and_free(CCC_Bitset *bitset, CCC_Allocator const *allocator)
Clears the bit set by setting the size to 0 and freeing the underlying memory. Capacity becomes 0 as ...
CCC_Tribool CCC_bitset_any_range(CCC_Bitset const *bitset, size_t range_start_index, size_t range_bit_count)
Return true if any bits are 1 in the range [index, index + count).
CCC_Result CCC_bitset_shift_right(CCC_Bitset *bitset, size_t right_shifts)
Shift the bit set right by right_shifts amount.
CCC_Count CCC_bitset_first_trailing_ones(CCC_Bitset const *bitset, size_t ones_count)
Returns the index of the start of the first trailing number of contiguous 1 bits.
CCC_Result CCC_bitset_set_all(CCC_Bitset *bitset, CCC_Tribool bit)
Set all the bits to the provided value (CCC_TRUE or CCC_FALSE).
CCC_Tribool CCC_bitset_set(CCC_Bitset *bitset, size_t index, CCC_Tribool bit)
Set the bit at valid index index to value bit (true or false).
CCC_Count CCC_bitset_first_leading_ones(CCC_Bitset const *bitset, size_t ones_count)
Returns the index of the start of the first leading bit_count contiguous 1 bits.
CCC_Count CCC_bitset_first_leading_zero_range(CCC_Bitset const *bitset, size_t range_start_index, size_t range_bit_count)
Return the index of the first leading bit set to 0 in the range [i, index + count).
CCC_Result CCC_bitset_reserve(CCC_Bitset *bitset, size_t to_add, CCC_Allocator const *allocator)
Reserves space for at least to_add more bits.
CCC_Result CCC_bitset_reset_range(CCC_Bitset *bitset, size_t range_start_index, size_t range_bit_count)
Set all the bits in the specified range starting at the Least Significant Bit of the range and ending...
CCC_Count CCC_bitset_first_trailing_one_range(CCC_Bitset const *bitset, size_t range_start_index, size_t range_bit_count)
Return the index of the first trailing bit set to 1 in the range [i, index + count).
CCC_Count CCC_bitset_first_trailing_zero_range(CCC_Bitset const *bitset, size_t range_start_index, size_t range_bit_count)
Return the index of the first bit set to 0 in the range [i, index + count).
CCC_Count CCC_bitset_blocks_capacity(CCC_Bitset const *bitset)
Return number of CCC_bitblocks used by bit set for capacity bits.
CCC_Result CCC_bitset_set_range(CCC_Bitset *bitset, size_t range_start_index, size_t range_bit_count, CCC_Tribool bit)
Set all the bits in the specified range starting at the Least Significant Bit of the range and ending...
uint8_t CCC_Bit
A type to represent a single bit in the bit set.
Definition: bitset.h:79
CCC_Count CCC_bitset_first_trailing_zeros(CCC_Bitset const *bitset, size_t zeros_count)
Returns the index of the start of the first trailing number of contiguous 0 bits in the set.
CCC_Result CCC_bitset_or(CCC_Bitset *destination, CCC_Bitset const *source)
Bitwise OR destination set with source set.
CCC_Tribool CCC_bitset_none(CCC_Bitset const *bitset)
Return true if all bits are set to 0.
CCC_Result CCC_bitset_shift_left(CCC_Bitset *bitset, size_t left_shifts)
Shift the bit set left by left_shifts amount.
CCC_Count CCC_bitset_first_trailing_zeros_range(CCC_Bitset const *bitset, size_t range_start_index, size_t range_bit_count, size_t zeros_count)
Returns the index of the start of the first trailing zeros_count contiguous 0 bits in the range [i,...
CCC_Tribool CCC_bitset_is_subset(CCC_Bitset const *subset, CCC_Bitset const *set)
Return CCC_TRUE if subset is a subset of set (subset ⊆ set).
CCC_Tribool CCC_bitset_none_range(CCC_Bitset const *bitset, size_t range_start_index, size_t range_bit_count)
Return true if all bits are 0 in the range [index, index + count).
CCC_Result CCC_bitset_push_back(CCC_Bitset *bitset, CCC_Tribool bit, CCC_Allocator const *allocator)
Append a bit value to the set as the new Most Significant Bit.
CCC_Count CCC_bitset_first_leading_zeros_range(CCC_Bitset const *bitset, size_t range_start_index, size_t range_bit_count, size_t zeros_count)
Returns the index of the start of the first leading number of contiguous 0 bits in the range [i,...
void * CCC_bitset_data(CCC_Bitset const *bitset)
Return a reference to the base of the underlying block array.
CCC_Tribool CCC_bitset_is_empty(CCC_Bitset const *bitset)
Return true if no bits are actively tracked by the user and set.
CCC_Count CCC_bitset_capacity(CCC_Bitset const *bitset)
Return total number of bits the capacity of the set can hold.
CCC_Count CCC_bitset_popcount_range(CCC_Bitset const *bitset, size_t range_start_index, size_t range_bit_count)
Return the number of bits set to CCC_TRUE in the range. O(n).
CCC_Count CCC_bitset_first_leading_ones_range(CCC_Bitset const *bitset, size_t range_start_index, size_t range_bit_count, size_t ones_count)
Returns the index of the start of the first leading bit_count contiguous 1 bits in the range [i,...
CCC_Count CCC_bitset_first_trailing_ones_range(CCC_Bitset const *bitset, size_t range_start_index, size_t range_bit_count, size_t ones_count)
Returns the index of the start of the first trailing number of contiguous 1 bits in the range [index,...
The type passed by reference to any container function that may need to allocate memory....
Definition: types.h:376
Definition: private_bitset.h:34
size_t count
Definition: private_bitset.h:38
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:244
The C Container Collection Fundamental Types.
CCC_Tribool
A three state boolean to allow for an error state. Error is -1, False is 0, and True is 1.
Definition: types.h:178
CCC_Result
A result of actions on containers.
Definition: types.h:192