Boost
arrow_drop_down
Boost.Bloom
M
D

本次发布

Joaquin M. López Muñoz
Joaquin M. López Muñoz
作者

依赖项

库依赖关系将很快生成,请稍后再查看。

Boost Bloom 库

Branch CI Drone status codecov Documentation
Branch CI Drone status codecov Documentation
BSL 1.0 C++11 required Header-only library

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

支持

贡献