OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_RAPPOR_BLOOM_FILTER_H_ | |
6 #define COMPONENTS_RAPPOR_BLOOM_FILTER_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <string> | |
11 #include <vector> | |
12 | |
13 #include "base/basictypes.h" | |
14 #include "components/rappor/byte_vector_utils.h" | |
15 | |
16 namespace rappor { | |
17 | |
18 // BloomFilter is a simple Bloom filter for keeping track of a set of strings. | |
19 class BloomFilter { | |
20 public: | |
21 // Constructs a BloomFilter using |bytes_size| bytes of Bloom filter bits, | |
22 // and |hash_function_count| hash functions to set bits in the filter. The | |
23 // hash functions will be generated by using seeds in the range | |
24 // |hash_seed_offset| to (|hash_seed_offset| + |hash_function_count|). | |
25 BloomFilter(uint32_t bytes_size, | |
26 uint32_t hash_function_count, | |
27 uint32_t hash_seed_offset); | |
28 ~BloomFilter(); | |
29 | |
30 // Add a single string to the Bloom filter. | |
31 void AddString(const std::string& str); | |
32 | |
33 // Returns the current value of the Bloom filter's bit array. | |
34 const ByteVector& bytes() const { return bytes_; }; | |
35 | |
36 // Returns the number of bits set for each string added to the filter. | |
37 uint32_t hash_function_count() const { return hash_function_count_; }; | |
Ilya Sherman
2014/02/13 01:39:03
nit: Why does this need to be publicly exported?
Steven Holte
2014/02/13 05:11:12
Done.
| |
38 | |
39 private: | |
40 // Stores the byte array of the Bloom filter. | |
41 ByteVector bytes_; | |
Ilya Sherman
2014/02/13 01:39:03
nit: Please leave blank lines between documented m
Steven Holte
2014/02/13 05:11:12
Done.
| |
42 // The number of bits to set for each string added. | |
43 uint32_t hash_function_count_; | |
44 uint32_t hash_seed_offset_; | |
Ilya Sherman
2014/02/13 01:39:03
nit: Please add documentation for this member vari
Steven Holte
2014/02/13 05:11:12
Done.
| |
45 | |
46 DISALLOW_COPY_AND_ASSIGN(BloomFilter); | |
47 }; | |
48 | |
49 } // namespace rappor | |
50 | |
51 #endif // COMPONENTS_RAPPOR_BLOOM_FILTER_H_ | |
OLD | NEW |