|
49 | 49 | extern "C" { |
50 | 50 | #endif |
51 | 51 |
|
| 52 | +/** A bitset data structure for compact boolean storage. */ |
52 | 53 | typedef struct ecs_bitset_t { |
53 | | - uint64_t *data; |
54 | | - int32_t count; |
55 | | - ecs_size_t size; |
| 54 | + uint64_t *data; /**< Array of 64-bit words storing the bits. */ |
| 55 | + int32_t count; /**< Number of bits in the bitset. */ |
| 56 | + ecs_size_t size; /**< Allocated capacity in 64-bit words. */ |
56 | 57 | } ecs_bitset_t; |
57 | 58 |
|
58 | | -/** Initialize bitset. */ |
| 59 | +/** Initialize a bitset. |
| 60 | + * |
| 61 | + * @param bs The bitset to initialize. |
| 62 | + */ |
59 | 63 | FLECS_DBG_API |
60 | 64 | void flecs_bitset_init( |
61 | 65 | ecs_bitset_t *bs); |
62 | 66 |
|
63 | | -/** Deinitialize bitset. */ |
| 67 | +/** Deinitialize a bitset. |
| 68 | + * |
| 69 | + * @param bs The bitset to deinitialize. |
| 70 | + */ |
64 | 71 | FLECS_DBG_API |
65 | 72 | void flecs_bitset_fini( |
66 | 73 | ecs_bitset_t *bs); |
67 | 74 |
|
68 | | -/** Add n elements to bitset. */ |
| 75 | +/** Add n elements to a bitset. |
| 76 | + * |
| 77 | + * @param bs The bitset to add to. |
| 78 | + * @param count Number of bits to add. |
| 79 | + */ |
69 | 80 | FLECS_DBG_API |
70 | 81 | void flecs_bitset_addn( |
71 | 82 | ecs_bitset_t *bs, |
72 | 83 | int32_t count); |
73 | 84 |
|
74 | | -/** Ensure element exists. */ |
| 85 | +/** Ensure an element exists. |
| 86 | + * |
| 87 | + * @param bs The bitset to ensure capacity for. |
| 88 | + * @param count Minimum number of bits the bitset must hold. |
| 89 | + */ |
75 | 90 | FLECS_DBG_API |
76 | 91 | void flecs_bitset_ensure( |
77 | 92 | ecs_bitset_t *bs, |
78 | 93 | int32_t count); |
79 | 94 |
|
80 | | -/** Set element. */ |
| 95 | +/** Set an element. |
| 96 | + * |
| 97 | + * @param bs The bitset to modify. |
| 98 | + * @param elem Index of the bit to set. |
| 99 | + * @param value The boolean value to set. |
| 100 | + */ |
81 | 101 | FLECS_DBG_API |
82 | 102 | void flecs_bitset_set( |
83 | 103 | ecs_bitset_t *bs, |
84 | 104 | int32_t elem, |
85 | 105 | bool value); |
86 | 106 |
|
87 | | -/** Get element. */ |
| 107 | +/** Get an element. |
| 108 | + * |
| 109 | + * @param bs The bitset to read from. |
| 110 | + * @param elem Index of the bit to get. |
| 111 | + * @return The boolean value of the bit. |
| 112 | + */ |
88 | 113 | FLECS_DBG_API |
89 | 114 | bool flecs_bitset_get( |
90 | 115 | const ecs_bitset_t *bs, |
91 | 116 | int32_t elem); |
92 | 117 |
|
93 | | -/** Return number of elements. */ |
| 118 | +/** Return the number of elements. |
| 119 | + * |
| 120 | + * @param bs The bitset. |
| 121 | + * @return The number of bits in the bitset. |
| 122 | + */ |
94 | 123 | FLECS_DBG_API |
95 | 124 | int32_t flecs_bitset_count( |
96 | 125 | const ecs_bitset_t *bs); |
97 | 126 |
|
98 | | -/** Remove from bitset. */ |
| 127 | +/** Remove from a bitset. |
| 128 | + * |
| 129 | + * @param bs The bitset to remove from. |
| 130 | + * @param elem Index of the bit to remove. |
| 131 | + */ |
99 | 132 | FLECS_DBG_API |
100 | 133 | void flecs_bitset_remove( |
101 | 134 | ecs_bitset_t *bs, |
102 | 135 | int32_t elem); |
103 | 136 |
|
104 | | -/** Swap values in bitset. */ |
| 137 | +/** Swap values in a bitset. |
| 138 | + * |
| 139 | + * @param bs The bitset. |
| 140 | + * @param elem_a Index of the first bit to swap. |
| 141 | + * @param elem_b Index of the second bit to swap. |
| 142 | + */ |
105 | 143 | FLECS_DBG_API |
106 | 144 | void flecs_bitset_swap( |
107 | 145 | ecs_bitset_t *bs, |
|
0 commit comments