C++ 11 发布于 Boost 1.89.0
类别: 容器
布隆过滤器。
本次发布
依赖项
库依赖关系将很快生成,请稍后再查看。
Boost Bloom 库
Boost.Bloom 提供了类模板 boost::bloom::filter
,可以配置为实现经典的 Bloom 过滤器 以及文献中讨论的变体,如块过滤器、多块过滤器等。
#include <boost/bloom/filter.hpp>
#include <cassert>
#include <string>
int main()
{
// Bloom filter of strings with 5 bits set per insertion
using filter = boost::bloom::filter<std::string, 5>;
// create filter with a capacity of 1'000'000 **bits**
filter f(1'000'000);
// insert elements (they can't be erased, Bloom filters are insert-only)
f.insert("hello");
f.insert("Boost");
//...
// elements inserted are always correctly checked as such
assert(f.may_contain("hello") == true);
// elements not inserted may incorrectly be identified as such with a
// false positive rate (FPR) which is a function of the array capacity,
// the number of bits set per element and generally how the boost::bloom::filter
// was specified
if(f.may_contain("bye")) { // likely false
//...
}
}
了解 Boost.Bloom
安装 Boost.Bloom
- 下载 Boost 即可开始使用(这是一个仅头文件库,无需编译)。
- 使用 Conan 2:如果您还没有,请在您的
conanfile.txt
中添加 Boost 条目(示例要求至少 Boost 1.89)
[requires]
boost/[>=1.89.0]
- 如果您不使用任何编译的 Boost 库,以下操作将跳过编译
[options]
boost:header_only=True
- 使用 vcpkg:执行命令
vcpkg install boost-bloom
- 使用 CMake:Boost CMake 支持基础设施允许您直接使用 CMake 下载、构建和使用所有 Boost 或特定库。
支持
- 加入 cpplang.slack.com 上的 **#boost** 讨论组(如果您还不是该工作区的成员,请 申请邀请)
- 提交问题
贡献
- 非常欢迎针对 develop 分支的 Pull requests。请注意,提交补丁即表示您同意根据 Boost Software License, Version 1.0 许可您的修改。