Add new BiF for low-level Bloom filter initialization.

For symmetry reasons, the new Bif bloomfilter_basic_init2 also allows users to
manually specify the memory bounds and number of hash functions to use.
This commit is contained in:
Matthias Vallentin 2013-07-31 18:21:37 +02:00
parent 8ca76dd4ee
commit d50b8a147d
4 changed files with 67 additions and 12 deletions

View file

@ -17,6 +17,8 @@ error: false-positive rate must take value between 0 and 1
1
1
1
1
1
2
3
3

View file

@ -15,6 +15,13 @@ function test_basic_bloom_filter()
bloomfilter_add(bf_cnt, 0.5); # Type mismatch
bloomfilter_add(bf_cnt, "foo"); # Type mismatch
# Alternative constructor.
local bf_dbl = bloomfilter_basic_init2(4, 10);
bloomfilter_add(bf_dbl, 4.2);
bloomfilter_add(bf_dbl, 3.14);
print bloomfilter_lookup(bf_dbl, 4.2);
print bloomfilter_lookup(bf_dbl, 3.14);
# Basic usage with strings.
local bf_str = bloomfilter_basic_init(0.9, 10);
bloomfilter_add(bf_str, "foo");