C / C ++中的动态位向量 [英] Dynamic bit vector in C/C++

查看:188
本文介绍了C / C ++中的动态位向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个现成的动态位向量在C或C + +,我可以使用。不幸的是由于各种原因,我目前不能使用BoosT库。 std:bitvector看起来很有希望,但它是模板,所以我不能动态设置位向量的长度。任何人可以建议?谢谢!

I am looking for an off-the-shelf dynamic bit vector in C or C++ that I can use. Unfortunately for various reasons I cannot use the BoosT libraries at the moment. std:bitvector looks promising but it is templated so I cannot set the length of the bit vector dynamically. Can anyone advise? Thanks!

推荐答案

您不必对boost及其安装过程添加依赖关系,只需使用 dynamic_bitset 。如果类适合你的目的,将源文件专门复制到你的项目树中,并将它放在一个单独的命名空间boostcopy(或类似的东西)。

You don't have to put a dependency onto all of boost and its installation process just to use dynamic_bitset. If the class suits your purposes, copy the source files for it specifically into your project tree and put it in a separate namespace called "boostcopy" (or something like that).

在类似的注释,我做了我自己的可调整大小的数组类后dynamic_bitset称为Nstate,你可以模板到任意基数,仍然得到紧包装。也许感兴趣:

On a similar note, I made my own resizable array class modeled after dynamic_bitset called "Nstate", which you can template to an arbitrary radix and still get tight packing. Perhaps of interest:

http://hostilefork.com/nstate /

这篇关于C / C ++中的动态位向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆