You are viewing the master version of this library.
The master and develop pages are shown here to provide access to the newest in-development in-progress documentation. See the "Documentation" link on this page.
Other aspects of the page will reflect the previous official version, or not be available until the next release.
Boost.Bloom provides the class template boost::bloom::filter that
can be configured to implement a classical Bloom filter
as well as variations discussed in the literature such as block filters, multiblock filters, and more.
#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
//...
}
}
conanfile.txt (the example requires at least Boost 1.89):[requires]
boost/[>=1.89.0]
[options]
boost:header_only=True
vcpkg install boost-bloom
<h1>Boost Bloom Library</h1> <p><a href="https://github.com/boostorg/bloom/tree/master"><img src="https://img.shields.io/badge/branch-master-brightgreen.svg" alt="Branch" /></a> <a href="https://github.com/boostorg/bloom/actions/workflows/ci.yml"><img src="https://github.com/boostorg/bloom/actions/workflows/ci.yml/badge.svg?branch=master" alt="CI" /></a> <a href="https://drone.cpp.al/boostorg/bloom"><img src="https://img.shields.io/drone/build/boostorg/bloom/master?server=https%3A%2F%2Fdrone.cpp.al&logo=drone&logoColor=%23CCCCCC&label=CI" alt="Drone status" /></a> <a href="https://app.codecov.io/gh/joaquintides/bloom/tree/master"><img src="https://codecov.io/gh/joaquintides/bloom/branch/master/graph/badge.svg" alt="codecov" /></a> <a href="https://boost.org/doc/libs/master/libs/bloom"><img src="https://img.shields.io/badge/docs-master-brightgreen.svg" alt="Documentation" /></a> </br> <a href="https://github.com/boostorg/bloom/tree/develop"><img src="https://img.shields.io/badge/branch-develop-brightgreen.svg" alt="Branch" /></a> <a href="https://github.com/boostorg/bloom/actions/workflows/ci.yml"><img src="https://github.com/boostorg/bloom/actions/workflows/ci.yml/badge.svg?branch=develop" alt="CI" /></a> <a href="https://drone.cpp.al/boostorg/bloom"><img src="https://img.shields.io/drone/build/boostorg/bloom/develop?server=https%3A%2F%2Fdrone.cpp.al&logo=drone&logoColor=%23CCCCCC&label=CI" alt="Drone status" /></a> <a href="https://app.codecov.io/gh/joaquintides/bloom/tree/develop"><img src="https://codecov.io/gh/joaquintides/bloom/branch/develop/graph/badge.svg" alt="codecov" /></a> <a href="https://boost.org/doc/libs/develop/libs/bloom"><img src="https://img.shields.io/badge/docs-develop-brightgreen.svg" alt="Documentation" /></a> </br> <a href="https://www.boost.org/users/license.html"><img src="https://img.shields.io/badge/license-BSL_1.0-blue.svg" alt="BSL 1.0" /></a> <img alt="C++11 required" src="https://img.shields.io/badge/standard-C%2b%2b11-blue.svg"> <img alt="Header-only library" src="https://img.shields.io/badge/build-header--only-blue.svg"></p> <p>Boost.Bloom provides the class template <code>boost::bloom::filter</code> that can be configured to implement a classical <a href="https://en.wikipedia.org/wiki/Bloom_filter">Bloom filter</a> as well as variations discussed in the literature such as block filters, multiblock filters, and more.</p> <pre class="highlightjs highlight"><code class="language-cpp hljs">#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 //... } } </code></pre> <h2>Learn about Boost.Bloom</h2> <ul> <li><a href="https://boost.org/libs/bloom">Online documentation</a></li> <li><a href="https://github.com/boostorg/boost_bloom_benchmarks">Some benchmarks</a></li> </ul> <h2>Install Boost.Bloom</h2> <ul> <li><a href="https://www.boost.org/users/download/">Download Boost</a> and you're ready to go (this is a header-only library requiring no building).</li> <li>Using Conan 2: In case you don't have it yet, add an entry for Boost in your <code>conanfile.txt</code> (the example requires at least Boost 1.89):</li> </ul> <pre class="highlightjs highlight"><code class="language- hljs">[requires] boost/[>=1.89.0] </code></pre> <ul>If you're not using any compiled Boost library, the following will skip building altogether:</ul> <pre class="highlightjs highlight"><code class="language- hljs">[options] boost:header_only=True </code></pre> <ul> <li>Using vcpkg: Execute the command</li> </ul> <pre class="highlightjs highlight"><code class="language- hljs">vcpkg install boost-bloom </code></pre> <ul> <li>Using CMake: <a href="https://github.com/boostorg/cmake">Boost CMake support infrastructure</a> allows you to use CMake directly to download, build and consume all of Boost or some specific libraries.</li> </ul> <h2>Support</h2> <ul> <li>Join the <strong>#boost</strong> discussion group at <a href="https://cpplang.slack.com/">cpplang.slack.com</a> (<a href="https://cppalliance.org/slack/">ask for an invite</a> if you’re not a member of this workspace yet)</li> <li><a href="https://github.com/boostorg/bloom/issues">File an issue</a></li> </ul> <h2>Contribute</h2> <ul> <li><a href="https://github.com/boostorg/bloom/pulls">Pull requests</a> against <strong>develop</strong> branch are most welcome. Note that by submitting patches you agree to license your modifications under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</li> </ul>
<h1>Boost Bloom Library</h1> <p><a href="https://github.com/boostorg/bloom/tree/master"><img src="https://img.shields.io/badge/branch-master-brightgreen.svg" alt="Branch" /></a> <a href="https://github.com/boostorg/bloom/actions/workflows/ci.yml"><img src="https://github.com/boostorg/bloom/actions/workflows/ci.yml/badge.svg?branch=master" alt="CI" /></a> <a href="https://drone.cpp.al/boostorg/bloom"><img src="https://img.shields.io/drone/build/boostorg/bloom/master?server=https%3A%2F%2Fdrone.cpp.al&logo=drone&logoColor=%23CCCCCC&label=CI" alt="Drone status" /></a> <a href="https://app.codecov.io/gh/joaquintides/bloom/tree/master"><img src="https://codecov.io/gh/joaquintides/bloom/branch/master/graph/badge.svg" alt="codecov" /></a> <a href="https://boost.org/doc/libs/master/libs/bloom"><img src="https://img.shields.io/badge/docs-master-brightgreen.svg" alt="Documentation" /></a> </br> <a href="https://github.com/boostorg/bloom/tree/develop"><img src="https://img.shields.io/badge/branch-develop-brightgreen.svg" alt="Branch" /></a> <a href="https://github.com/boostorg/bloom/actions/workflows/ci.yml"><img src="https://github.com/boostorg/bloom/actions/workflows/ci.yml/badge.svg?branch=develop" alt="CI" /></a> <a href="https://drone.cpp.al/boostorg/bloom"><img src="https://img.shields.io/drone/build/boostorg/bloom/develop?server=https%3A%2F%2Fdrone.cpp.al&logo=drone&logoColor=%23CCCCCC&label=CI" alt="Drone status" /></a> <a href="https://app.codecov.io/gh/joaquintides/bloom/tree/develop"><img src="https://codecov.io/gh/joaquintides/bloom/branch/develop/graph/badge.svg" alt="codecov" /></a> <a href="https://boost.org/doc/libs/develop/libs/bloom"><img src="https://img.shields.io/badge/docs-develop-brightgreen.svg" alt="Documentation" /></a> </br> <a href="https://www.boost.org/users/license.html"><img src="https://img.shields.io/badge/license-BSL_1.0-blue.svg" alt="BSL 1.0" /></a> <img alt="C++11 required" src="https://img.shields.io/badge/standard-C%2b%2b11-blue.svg"> <img alt="Header-only library" src="https://img.shields.io/badge/build-header--only-blue.svg"></p> <p>Boost.Bloom provides the class template <code>boost::bloom::filter</code> that can be configured to implement a classical <a href="https://en.wikipedia.org/wiki/Bloom_filter">Bloom filter</a> as well as variations discussed in the literature such as block filters, multiblock filters, and more.</p> <pre class="highlightjs highlight"><code class="language-cpp hljs">#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 //... } } </code></pre> <h2>Learn about Boost.Bloom</h2> <ul> <li><a href="https://boost.org/libs/bloom">Online documentation</a></li> <li><a href="https://github.com/boostorg/boost_bloom_benchmarks">Some benchmarks</a></li> </ul> <h2>Install Boost.Bloom</h2> <ul> <li><a href="https://www.boost.org/users/download/">Download Boost</a> and you're ready to go (this is a header-only library requiring no building).</li> <li>Using Conan 2: In case you don't have it yet, add an entry for Boost in your <code>conanfile.txt</code> (the example requires at least Boost 1.89):</li> </ul> <pre class="highlightjs highlight"><code class="language- hljs">[requires] boost/[>=1.89.0] </code></pre> <ul>If you're not using any compiled Boost library, the following will skip building altogether:</ul> <pre class="highlightjs highlight"><code class="language- hljs">[options] boost:header_only=True </code></pre> <ul> <li>Using vcpkg: Execute the command</li> </ul> <pre class="highlightjs highlight"><code class="language- hljs">vcpkg install boost-bloom </code></pre> <ul> <li>Using CMake: <a href="https://github.com/boostorg/cmake">Boost CMake support infrastructure</a> allows you to use CMake directly to download, build and consume all of Boost or some specific libraries.</li> </ul> <h2>Support</h2> <ul> <li>Join the <strong>#boost</strong> discussion group at <a href="https://cpplang.slack.com/">cpplang.slack.com</a> (<a href="https://cppalliance.org/slack/">ask for an invite</a> if you’re not a member of this workspace yet)</li> <li><a href="https://github.com/boostorg/bloom/issues">File an issue</a></li> </ul> <h2>Contribute</h2> <ul> <li><a href="https://github.com/boostorg/bloom/pulls">Pull requests</a> against <strong>develop</strong> branch are most welcome. Note that by submitting patches you agree to license your modifications under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</li> </ul>