Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic bit vector in C/C++

Tags:

c++

bitmap

I am looking for an off-the-shelf dynamic bit vector in C or C++ that I can use. Unfortunately for various reasons I cannot use the BoosT libraries at the moment. std:bitvector looks promising but it is templated so I cannot set the length of the bit vector dynamically. Can anyone advise? Thanks!

like image 885
dustin ledezma Avatar asked Feb 15 '26 21:02

dustin ledezma


2 Answers

You don't have to put a dependency onto all of boost and its installation process just to use dynamic_bitset. If the class suits your purposes, copy the source files for it specifically into your project tree and put it in a separate namespace called "boostcopy" (or something like that).

On a similar note, I made my own resizable array class modeled after dynamic_bitset called "Nstate", which you can template to an arbitrary radix and still get tight packing. Perhaps of interest:

http://hostilefork.com/nstate/

like image 182
HostileFork says dont trust SE Avatar answered Feb 18 '26 11:02

HostileFork says dont trust SE


I have never used vector<bool> (See Scott Meyers' Effective STL item 18) but it might be just what you are looking for.

like image 44
IronMensan Avatar answered Feb 18 '26 11:02

IronMensan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!