Name: bloom-filter-cpp
Owner: Brave Software
Description: null
Created: 2016-01-21 21:55:36.0
Updated: 2018-03-25 02:14:01.0
Pushed: 2018-03-25 02:14:00.0
Homepage: null
Size: 53
Language: C++
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
C++ Native node module Bloom filter written in C++ for use in node or any other C++ project.
The Bloom filter tests whether an element belongs to a set. False positive matches are possible but not common, false negatives are not possible. The Bloom filter library also implements Rabin?Karp algorithm with Rabin fingerprint hashes for multiple substring searches.
This is a port of a similar lib I prototyped in JS.
install --save bloom-filter-cpp
BloomFilter = require('bloom-filter-cpp').BloomFilter
b1 = new BloomFilter()
ole.log('b1 ading hello')
dd('hello')
ole.log('b1 exists hello? ', b1.exists('hello'))
ole.log('b1 exists hello2? ', b1.exists('hello2'))
b2 = new BloomFilter()
ole.log('b2 exists hello? ', b2.exists('hello'))
ole.log('b2 exists hello2? ', b2.exists('hello2'))
lude "BloomFilter.h"
lude <iostream>
g namespace std;
main(int argc, char**argv) {
oomFilter b;
add("Brian");
add("Ronald");
add("Bondy");
Prints true
ut << (b.exists("Brian") ? "true" : "false") << endl;
Prints false
ut << (b.exists("Brian Ronald") ? "true" : "false") << endl;
Create a new BloomerFilter form a previous serialization
oomFilter b2(b.getBuffer(), b.getByteBufferSize());
Prints the same as above
ut << (b2.exists("Brian") ? "true" : "false") << endl;
ut << (b2.exists("Brian Ronald") ? "true" : "false") << endl;
And you can check if any substring of a passed string exists
Prints true
ut << (b.substringExists("Hello my name is Brian", 5) ? "true" : "false") << endl;
Prints false
ut << (b.substringExists("Hello my name is Bri", 3) ? "true" : "false") << endl;
turn 0;
clone bloom-filter-cpp
install
sample
test
clean