bloom.h (497B)
1 #ifndef BLOOM_H 2 #define BLOOM_H 3 4 #include <assert.h> 5 #include <flint.h> 6 #include <fmpz.h> 7 #include <stdint.h> 8 #include <stdlib.h> 9 10 typedef struct { 11 size_t n; 12 uint8_t *buffer; 13 } bitvec_t; 14 15 typedef struct { 16 size_t k; // number of hash functions 17 bitvec_t bv; 18 } bloom_t; 19 20 void bloom_init(bloom_t *bloom, const size_t k, const size_t m); 21 void bloom_clear(bloom_t *bloom); 22 void bloom_insert(bloom_t *bloom, const fmpz_t n); 23 int bloom_prob_contains(const bloom_t *bloom, const fmpz_t n); 24 25 #endif