16#ifndef CCC_PRIVATE_BITSET
17#define CCC_PRIVATE_BITSET
49 CCC_PRIVATE_BITSET_BLOCK_BITS
50 = (
sizeof(*(
struct CCC_Bitset){}.blocks) * CHAR_BIT),
63#define CCC_private_bitset_block_count(private_bit_cap) \
64 (((private_bit_cap) + (CCC_PRIVATE_BITSET_BLOCK_BITS - 1)) \
65 / CCC_PRIVATE_BITSET_BLOCK_BITS)
68#define CCC_private_bitset_block_bytes(private_bit_cap) \
69 (sizeof(*(struct CCC_Bitset){}.blocks) * (private_bit_cap))
74#define CCC_private_bitset_blocks(private_bit_cap, ...) \
75 (__VA_OPT__(__VA_ARGS__) typeof ( \
76 *(struct CCC_Bitset){} \
77 .blocks)[CCC_private_bitset_block_count(private_bit_cap)]) \
81#define CCC_private_bitset_non_CCC_private_bitset_default_size(private_cap, \
85#define CCC_private_bitset_default_size(private_cap, ...) private_cap
87#define CCC_private_bitset_optional_size(private_cap, ...) \
88 __VA_OPT__(CCC_private_bitset_non_) \
89 ##CCC_private_bitset_default_size(private_cap, __VA_ARGS__)
96#define CCC_private_bitset_initialize(private_bitblock_pointer, \
97 private_allocate, private_context, \
100 .blocks = (private_bitblock_pointer), \
101 .count = CCC_private_bitset_optional_size((private_cap), __VA_ARGS__), \
102 .capacity = (private_cap), \
103 .allocate = (private_allocate), \
104 .context = (private_context), \
113 size_t i,
size_t const count,
size_t cap,
114 char const on_char,
char const *string)
117 if (CCC_private_bitset_reserve(&b, cap <
count ?
count : cap, fn)
123 while (i <
count &&
string[i])
125 (void)CCC_private_bitset_set(&b, i,
string[i] == on_char);
136 void *
const context,
size_t const cap,
140 if (CCC_private_bitset_reserve(&b, cap, fn) ==
CCC_RESULT_OK)
149#define CCC_private_bitset_from(private_allocate, private_context, \
150 private_start_index, private_count, \
151 private_on_char, private_string, ...) \
152 CCC_private_bitset_from_fn( \
153 private_allocate, private_context, private_start_index, private_count, \
154 CCC_private_bitset_optional_size((private_count), __VA_ARGS__), \
155 private_on_char, private_string)
158#define CCC_private_bitset_with_capacity(private_allocate, private_context, \
160 CCC_private_bitset_with_capacity_fn( \
161 private_allocate, private_context, private_cap, \
162 CCC_private_bitset_optional_size((private_cap), __VA_ARGS__))
Definition: private_bitset.h:33
void * context
Definition: private_bitset.h:43
unsigned * blocks
Definition: private_bitset.h:35
CCC_Allocator * allocate
Definition: private_bitset.h:41
size_t count
Definition: private_bitset.h:37
size_t capacity
Definition: private_bitset.h:39
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:133
CCC_Result
A result of actions on containers.
Definition: types.h:148
@ CCC_RESULT_OK
Definition: types.h:150
void * CCC_Allocator(CCC_Allocator_context)
An allocation function at the core of all containers.
Definition: types.h:340