GitXplorerGitXplorer
s

dynamic_bitset

public
10 stars
1 forks
1 issues

Commits

List of commits on branch master.
Unverified
5420fa948c5c59df6f979c723306648ccdb63a05

Change the behavior of `size()`. it now returns the number of bits, not bytes.

ssyoyo committed 5 years ago
Unverified
ca3584f937196b7a300aa8daf952b909b57cdb12

Mark count() method const.

ssyoyo committed 5 years ago
Unverified
7df870b2edfbee3295e6db49c2ec2a0e0019f299

Add non-const data() method.

ssyoyo committed 5 years ago
Unverified
5d3cb89d9d78904b550e552c5a7a2160f06bad07

Add size(), nbits() and data().

ssyoyo committed 5 years ago
Unverified
ce73f9880d3901c5cea73dc57aba6a6dc90d81bb

Cosmetics.

ssyoyo committed 5 years ago
Unverified
eda9a3265e04d8b64d1927d4bd5979aafbc22c3f

Update README.

ssyoyo committed 5 years ago

README

The README file for this repository.

Simple dynamic_bitset implementation in C++11

Build Status

dynamic_bitset is implemented as a template class, so you can just include the header file to use it. dynamic_bitset does not depend any library except for STL.

Requirements

  • C++11 compiler

Usage

#include "dynamic_bitset.hh"

// init with 13 bits. fill bitfield with value `42`
dynamic_bitset db(13, 42);

// init with 0bits
dynamic_bitset db;

// resize to 12 bits
db.resize(12);

// resize does not initialize extended memory region.
// Use `reset()` to clear all bitfields.
db.reset();

// set 3rd bit true
db.set(3);

// get 5th bit state
std::cout << db[5] << "\n";

// print bitfield
std::cout << db.to_string() << "\n";

// set all bits with true or false
db.setall(true);

Note

dynamic_bitset has similar functions defined in std::bitset and std::vector. dynamic_bitset is not compatible with boost::dynamic_bitset

TODO

  • [ ] Implement more features.
  • [ ] Validate endianness.
  • [ ] Write more tests.

Similar projects

License

dynamic_bitset is licensed under MIT license.

Thrid party license

  • acutest : For unit test. MIT license.