Skip to content

Commit 16b2fcd

Browse files
committed
Rewrite API section in English
1 parent 462bd32 commit 16b2fcd

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,37 @@ Architecture: x86_64
5353
CPU(s): 5
5454
Model name: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
5555
```
56+
## API Reference
57+
58+
Below is a quick guide to the main `bowen::BitVector` functions:
59+
60+
- **`BitVector()`** – Construct an empty vector.
61+
- **`BitVector(size_t n, bool value = false)`** – Create a vector with `n` bits initialized to `value`.
62+
- **`operator[]`** – Access or modify a bit by index.
63+
- **`set_bit(size_t pos, bool value)`** – Set the bit at `pos` to `value`.
64+
- **`set_bit_true_unsafe(size_t pos)`** – Like `set_bit(pos, true)` but without bounds checking.
65+
- **`qset_bit_true_6_v2(size_t pos, size_t stride, size_t size)`** – Use SIMD to quickly set bits in a stride pattern.
66+
- **`set_bit_true_6(size_t pos, size_t stride)`** – Set six bits starting from `pos` with the given `stride`.
67+
- **`incrementUntilZero(size_t& pos)`** – Advance `pos` to the first zero bit from its current value.
68+
- **`push_back(bool value)`** – Append a bit to the end of the vector.
69+
- **`reserve(size_t new_capacity)`** – Ensure capacity for at least `new_capacity` bits.
70+
- **`assign(size_t n, bool value)`** – Resize the vector to `n` bits and set each bit to `value`.
71+
- **`data()`** – Pointer to the underlying storage.
72+
- **`size()`** – Number of bits currently stored.
73+
- **`empty()`** – Check whether the vector is empty.
74+
- **`begin()` / `end()`** – Iterators for range-based loops.
75+
76+
Example:
5677
78+
```cpp
79+
#include "bitvector.hpp"
80+
using bowen::BitVector;
81+
82+
int main() {
83+
BitVector<> bv(8); // all bits start as 0
84+
bv.set_bit(3, true); // set the fourth bit
85+
bv.push_back(true); // append one bit
86+
size_t pos = 0;
87+
bv.incrementUntilZero(pos); // pos now points to the first zero bit
88+
}
89+
```

0 commit comments

Comments
 (0)