F
fgh.vbn.rty
I know that std::vector<bool> is specialized to store individual bools
as single bits. I have a question about the comparison operation on a
pair of vector<bool>s.
Is the comparison done bit by bit? That would be slow. In theory it's
possible to just do a bit-wise XOR on all bits and then OR it all
together and compare the single bit right? That would make it O(1)
instead of O(n). What's bad about this method?
Does the size of the vector matter here? For instance if the vectors
are <= 32bits they can fit into two registers and it's easy to do the
XOR. But if they are more than that then it's more complicated
What about comparison on std::bitset? Does compare work the same way
for it?
And what about boost::dynamic_bitset? Any difference for that?
Thanks.
as single bits. I have a question about the comparison operation on a
pair of vector<bool>s.
Is the comparison done bit by bit? That would be slow. In theory it's
possible to just do a bit-wise XOR on all bits and then OR it all
together and compare the single bit right? That would make it O(1)
instead of O(n). What's bad about this method?
Does the size of the vector matter here? For instance if the vectors
are <= 32bits they can fit into two registers and it's easy to do the
XOR. But if they are more than that then it's more complicated
What about comparison on std::bitset? Does compare work the same way
for it?
And what about boost::dynamic_bitset? Any difference for that?
Thanks.