Possseidon / dang-lib

A C++ library, providing a variety of useful classes focused around game developement.
3 stars 1 forks source link

Implement my own dynamically sized bitset. #120

Open Possseidon opened 2 years ago

Possseidon commented 2 years ago

I tried using boost::dynamic_bitset, but it has a few issues with my specific use-cases...

So I'll just roll my own and make it ✨ super fancy ✨ as per usual!

There's some commits in this PR that I should probably cherry pick into some other branches.

Issues with boost::dynamic_bitset

  1. Applying logical operations requires bitsets to be of the same size for no good reason. ... which means, I have to allocate if I want to compare efficiently. Or I skip the resizing and compare manually but super slow..
  2. Comparisons are very odd and don't mimic the correct behavior of standard containers like std::vector<bool>. bitset[0] should be the most significant bit, yet bitset[word_bits - 1] seems to be the most significant.
  3. No way of finding the last set bit. Didn't really need it yet, but might come in handy at some point. Still dumb that it's missing.
  4. Brings in quite a bit of other boost stuff just for a bitset. Also, there's no CMake targets because it's header only... Ever heared of INTERFACE targets? sigh

So yeah... Reinventing the wheel once again!