开发者

bitset or native data types with bitwise operations for bitmap?

I would like to implement bitmaps of 64 bits, 128 bits and 256 bits. I was thinking of using specialized classes for these three. I need to开发者_StackOverflow社区 set the bits and also look them up. The bitset will not be dynamic, static implementations of 64, 128 and 256 bits will be used.

What are the pros and cons of using the c++ bitset over using a native type like long long and manipulating the bits using bitwise operations?

Is there any overhead in using bitset in initialization or in any other factor?

Thanks


Well, definitely there is some overhead in standard bitsets. Your implementation is going to be faster (but you need to invest some effort in coding it and making it efficient and bug-free).

I would however use standard bitsets and not fight against that overhead until this is a proven bottleneck. You know the often cited saying about about premature optimization, right?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜