• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    C++
  • Created almost 14 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C++ Bloom Filter Library https://www.partow.net/programming/bloomfilter/index.html

Description

C++ Bloom Filter Library, has the following capabilities:

  • Optimal parameter selection based on expected false positive rate.
  • Union, intersection and difference operations between bloom filters.
  • Compression of in-use table (increase of false positive probability vs space)
  • Portable and efficient source code implementation.
  • Single header implementation, no building required. No external dependencies

Compatible Compilers

  • GNU Compiler Collection (4.1+)
  • Intelยฎ C++ Compiler (9.x+)
  • Clang/LLVM (1.1+)
  • PGI C++ (10.x+)
  • Microsoft Visual Studio C++ Compiler (8.1+)

For more information please visit: http://www.partow.net/programming/bloomfilter/index.html


Simple Bloom Filter Example

Example's objectives:

  • Instantiate and configure a Bloom filter
  • Add some strings and integers to the Bloom filter
  • Query the Bloom filter for membership of the previously added strings and integers
  • Query the Bloom filter for membership of integers that were NOT previously added (potential false positives)
#include <iostream>
#include <string>

#include "bloom_filter.hpp"

int main()
{

   bloom_parameters parameters;

   // How many elements roughly do we expect to insert?
   parameters.projected_element_count = 1000;

   // Maximum tolerable false positive probability? (0,1)
   parameters.false_positive_probability = 0.0001; // 1 in 10000

   // Simple randomizer (optional)
   parameters.random_seed = 0xA5A5A5A5;

   if (!parameters)
   {
      std::cout << "Error - Invalid set of bloom filter parameters!" << std::endl;
      return 1;
   }

   parameters.compute_optimal_parameters();

   //Instantiate Bloom Filter
   bloom_filter filter(parameters);

   std::string str_list[] = { "AbC", "iJk", "XYZ" };

   // Insert into Bloom Filter
   {
      // Insert some strings
      for (std::size_t i = 0; i < (sizeof(str_list) / sizeof(std::string)); ++i)
      {
         filter.insert(str_list[i]);
      }

      // Insert some numbers
      for (std::size_t i = 0; i < 100; ++i)
      {
         filter.insert(i);
      }
   }


   // Query Bloom Filter
   {
      // Query the existence of strings
      for (std::size_t i = 0; i < (sizeof(str_list) / sizeof(std::string)); ++i)
      {
         if (filter.contains(str_list[i]))
         {
            std::cout << "BF contains: " << str_list[i] << std::endl;
         }
      }

      // Query the existence of numbers
      for (std::size_t i = 0; i < 100; ++i)
      {
         if (filter.contains(i))
         {
            std::cout << "BF contains: " << i << std::endl;
         }
      }

      // Query the existence of invalid numbers
      for (int i = -1; i > -100; --i)
      {
         if (filter.contains(i))
         {
            std::cout << "BF falsely contains: " << i << std::endl;
         }
      }
   }

   return 0;
}

More Repositories

1

exprtk

C++ Mathematical Expression Parsing And Evaluation Library https://www.partow.net/programming/exprtk/index.html
C++
634
star
2

wykobi

Wykobi C++ Computational Geometry Library https://www.wykobi.com
C++
166
star
3

bitmap

C++ Bitmap Library https://www.partow.net/programming/bitmap/index.html
C++
165
star
4

proxy

C++ TCP Proxy Server https://www.partow.net/programming/tcpproxy/index.html
C++
146
star
5

math-parser-benchmark-project

C++ Mathematical Expression Parser Benchmark
C++
131
star
6

strtk

C++ String Toolkit Library https://www.partow.net/programming/strtk/index.html
C++
130
star
7

schifra

C++ Reed Solomon Error Correcting Library https://www.schifra.com
C++
52
star
8

lexertk

C++ Lexer Toolkit Library (LexerTk) https://www.partow.net/programming/lexertk/index.html
C++
30
star
9

hash

General Purpose Hash Function Algorithms https://www.partow.net/programming/hashfunctions/index.html
C++
19
star
10

exprtk-extras

C++ Mathematical Expression Library Extra Examples https://www.partow.net/programming/exprtk/index.html
C++
13
star
11

galois

C++ Galois Finite Field Arithmetic Library https://www.partow.net/projects/galois/index.html
C++
8
star
12

fastgeo

FastGEO Computational Geometry Library https://www.partow.net/projects/fastgeo/index.html
Pascal
7
star
13

tcpproxy-variations

C++ TCP Proxy Server Variations
C++
5
star
14

exprtk-custom-types

Exprtk Custom Numeric Types
C++
2
star
15

filter

C++ CSV and DSV Filter Library https://www.partow.net/programming/dsvfilter/index.html
C++
2
star
16

sumtk

C++ Summation Toolkit (SumTk) http://www.partow.net/programming/sumtk/index.html
C++
1
star
17

exprtk-perftest

C++
1
star
18

nanocalc

nanocalc lightweight scientific calculator
C++
1
star
19

registry

Win32 Registry Activity Monitor https://www.partow.net/programming/registrymonitor/index.html
Pascal
1
star