C/C++ 高效位数组 [英] C/C++ efficient bit array
本文介绍了C/C++ 高效位数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你能推荐有效/干净的方法来操作任意长度的位数组吗?
Can you recommend efficient/clean way to manipulate arbitrary length bit array?
现在我使用的是常规的 int/char 位掩码,但是当数组长度大于数据类型长度时,这些位掩码不是很干净.
Right now I am using regular int/char bitmask, but those are not very clean when array length is greater than datatype length.
std vector
对我不可用.
推荐答案
boost::dynamic_bitset
如果长度仅在运行时已知.
boost::dynamic_bitset
if the length is only known in run time.
std::bitset
如果长度在编译时已知(尽管是任意的).
std::bitset
if the length is known in compile time (although arbitrary).
这篇关于C/C++ 高效位数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文