Bit vector and bitset

本秂侑毒 提交于 2019-11-28 11:36:12

问题


What is the difference between bit-vector and bitset container of stl ? Please explain. To my understanding bitset is the implementation of the concept of bitvector am I right or wrong? What are the other ways to implement bit vector?


回答1:


bit_vector has the same interface as an std::vector, and is optimised for space. It not a part of standard C++. This documentation claims it is close to an STL vector<bool>, which presumably is quite close to a standard C++ std::vector<bool>.

std::bitset is fixed size, and has a different interface.




回答2:


They're different. A std::bitset has a fixed size known at compile time. This allows it to be implemented very efficiently. A bit vector (I assume you mean std::vector<bool>) can vary in size like any other std::vector.



来源:https://stackoverflow.com/questions/13321446/bit-vector-and-bitset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!