diff options
| author | Tyge Løvset <[email protected]> | 2022-05-22 20:45:31 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-05-22 20:45:31 +0200 |
| commit | 314a41be6b39b6c5967d79555dbf018dbc7eb5f6 (patch) | |
| tree | 881e2e6654a91357dfc225c9e67a80bfca37263c /docs/cbits_api.md | |
| parent | c0de7d59a09417e2e18909f808258e909c36ee09 (diff) | |
| download | STC-modified-314a41be6b39b6c5967d79555dbf018dbc7eb5f6.tar.gz STC-modified-314a41be6b39b6c5967d79555dbf018dbc7eb5f6.zip | |
Rewrote cbits to make it dual: fixed-sized or dynamically sized by adding optional i_len template parameter. Renamed cbits_set_values() to cbits_set_pattern(). Added example bits2.c
Diffstat (limited to 'docs/cbits_api.md')
| -rw-r--r-- | docs/cbits_api.md | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/docs/cbits_api.md b/docs/cbits_api.md index b9cf5069..b9d54737 100644 --- a/docs/cbits_api.md +++ b/docs/cbits_api.md @@ -1,7 +1,7 @@ # STC [cbits](../include/stc/cbits.h): Bitset  -A **cbits** represents a set of bits. It provides accesses to the value of individual bits via *cbits_test()* and provides the bitwise operators that one can apply to builtin integers. The number of bits in the set is specified at runtime via a parameter to the constructor *cbits_with_size()* or by *cbits_resize()*. A **cbits** bitset can be manipulated by standard logic operators and converted to and from strings. +A **cbits** represents either a fixed or a dynamically sized sequence of bits. It provides accesses to the value of individual bits via *cbits_test()* and provides the bitwise operators that one can apply to builtin integers. The number of bits in the set is specified at runtime via a parameter to the constructor *cbits_with_size()* or by *cbits_resize()*. A **cbits** bitset can be manipulated by standard logic operators and converted to and from strings. See the c++ class [std::bitset](https://en.cppreference.com/w/cpp/utility/bitset) or [boost::dynamic_bitset](https://www.boost.org/doc/libs/release/libs/dynamic_bitset/dynamic_bitset.html) @@ -12,21 +12,22 @@ for a functional description. All cbits definitions and prototypes are available by including a single header file. ```c +#define i_len N // if defined, the bitset will be fixed-size of N bits on the stack. +#define i_type name // optional, specifies the name of the bitset type. Default to cbits or cbitsN #include <stc/cbits.h> ``` ## Methods ```c cbits cbits_init(void); -cbits cbits_new(const char literal[]); cbits cbits_from(const char* str); -cbits cbits_with_size(size_t size, bool value); -cbits cbits_with_values(size_t size, uint64_t pattern); +cbits cbits_with_size(size_t size, bool value); // size must be <= N if N is defined +cbits cbits_with_pattern(size_t size, uint64_t pattern); cbits cbits_clone(cbits other); void cbits_clear(cbits* self); cbits* cbits_copy(cbits* self, cbits other); -void cbits_resize(cbits* self, size_t size, bool value); +void cbits_resize(cbits* self, size_t size, bool value); // only if i_len is not defined void cbits_drop(cbits* self); cbits* cbits_take(cbits* self, cbits other); // give other to self @@ -43,9 +44,9 @@ char* cbits_to_str(cbits set, char* str, size_t start, intptr_t stop) void cbits_set(cbits *self, size_t i); void cbits_reset(cbits *self, size_t i); -void cbits_set_all(cbits *self, bool value); void cbits_set_value(cbits *self, size_t i, bool value); -void cbits_set_values(cbits *self, uint64_t pattern); +void cbits_set_all(cbits *self, bool value); +void cbits_set_pattern(cbits *self, uint64_t pattern); void cbits_flip_all(cbits *self); void cbits_flip(cbits *self, size_t i); |
