TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Bloom Filter generic implementation in C++ More...
#include <cassert>
#include <functional>
#include <initializer_list>
#include <string>
#include <vector>
#include <iostream>
Go to the source code of this file.
Classes | |
class | data_structures::Bitset |
Simple bitset implementation for bloom filter. More... | |
class | data_structures::BloomFilter< T > |
Bloom filter template class. More... | |
Namespaces | |
namespace | data_structures |
for IO operations | |
Functions | |
static std::size_t | data_structures::hashDJB2 (std::string const &s) |
Function djb2 to get hash for the given string. | |
static std::size_t | data_structures::hashStr (std::string const &s) |
Hash function, to get hash for the given string. | |
std::size_t | data_structures::hashInt_1 (int x) |
Hash function for test | |
std::size_t | data_structures::hashInt_2 (int x) |
Hash function for test | |
static void | test_bloom_filter_string () |
Test for bloom filter with string as generic type. | |
static void | test_bloom_filter_int () |
Test for bloom filter with int as generic type. | |
static void | test_bitset () |
Test for bitset. | |
int | main () |
Main function. | |
Bloom Filter generic implementation in C++
A Bloom filter is a space-efficient probabilistic data structure, a query returns either "possibly in set" or "definitely not in set".
More generally, fewer than 10 bits per element are required for a 1% false positive probability, independent of the size or number of elements in the set.
It helps us to not make an "expensive operations", like disk IO - we can use bloom filter to check incoming request, and with a good probability get an answer of bloom filter, that we don't need to make our "expensive operation"
Basic bloom filter doesn't support deleting of elements, so we don't need to implement deletion in bloom filter and bitset in our case.
Definition in file bloom_filter.cpp.
int main | ( | void | ) |
Main function.
Definition at line 282 of file bloom_filter.cpp.
|
static |
Test for bitset.
Definition at line 267 of file bloom_filter.cpp.
|
static |
Test for bloom filter with int as generic type.
Definition at line 246 of file bloom_filter.cpp.
|
static |
Test for bloom filter with string as generic type.
Definition at line 226 of file bloom_filter.cpp.