Skip to main content

bitset vs vector

Posted in

It is a very popular question what are the differences between bitset and vector. Here they are (probably, these are the main differences, but not all of them, I guess)

bitset vector
Const size (once created) Yes No
Iterating through elements No Yes
Element search No Yes
Is container? No (bitset<T> makes no sense) Yes
Space allocation optimization? No Yes (see this.)

Looks like std::vector has knocked the bitset out.

implementation choice

You could find or make your own bitset implementation which isn't const-sized, allow iterating or element search, allow cycling or moving the bits, etc...

(but the reference class would still be almost the same as on the STL, it's a requirement because C/C++ doesn't allow direct bit management, only with mask and bit operation)

Won't I get something similar

Won't I get something similar to vector?

just a little, you could add

just a little, you could add features only usefull to bitset without having const-size once created, like the cycling or bit moving.

Post new comment

The content of this field is kept private and will not be shown publicly.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
         o      'O          o      O          Oo      oO 
O o O o .oOOo. O O o o
o O o O O o o O O
o o oO o O Oo O
`o O O O' O o Oo .oO O o
O o `o o o O o o o o O
o O `o O O o O O O o O
`o' `o' `OoO'o O o `OooO' O o

Enter the code depicted in ASCII art style.