Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add set/reset/flip functions to change sequences #27
Neither boost::dynamic_bitset nor vanilla std::bitset have the
Let's consider an example where we want either to set 1024 consecutive bits or to reset them (taking as the fact that we don't change the whole bitset, only its part).
I also updated docs, tests. Yeah, the algorithm can look a bit complicated, and there are 2 helper functions added, but there's nothing hard at all.
Any suggestions, notes on possible performance improvement, arguments meaning (we change here [first; last], but can change [first;last) as it's more STL-like style); maybe naming too? I guess
@@ Coverage Diff @@ ## develop #27 +/- ## =========================================== + Coverage 75.41% 76.76% +1.35% =========================================== Files 5 5 Lines 541 594 +53 Branches 198 210 +12 =========================================== + Hits 408 456 +48 - Misses 23 24 +1 - Partials 110 114 +4
This change is fine, however I think calling it set() makes more sense, and adding reset(f, l) and perhaps flip(f, l) so that all the bit manipulators can operate either on a single bit or a range of bits would complete the desired goal to modify sequences efficiently. As for the meaning of
@jeking3 I like your thoughts and agree with most of them.
Using relative last bit positions instead of absolute is done in std::string and it's logical to do the same here.
I decided to not call
But I have a serious doubt connected with implicit conversions from int to bool.
The last line was supposed to be
Other things seem fine to me, I'd make reset() and flip() with tests as well, after some time.