| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_RAPPOR_BLOOM_FILTER_H_ | 5 #ifndef COMPONENTS_RAPPOR_BLOOM_FILTER_H_ |
| 6 #define COMPONENTS_RAPPOR_BLOOM_FILTER_H_ | 6 #define COMPONENTS_RAPPOR_BLOOM_FILTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // hash functions will be generated by using seeds in the range | 21 // hash functions will be generated by using seeds in the range |
| 22 // |hash_seed_offset| to (|hash_seed_offset| + |hash_function_count|). | 22 // |hash_seed_offset| to (|hash_seed_offset| + |hash_function_count|). |
| 23 BloomFilter(uint32_t bytes_size, | 23 BloomFilter(uint32_t bytes_size, |
| 24 uint32_t hash_function_count, | 24 uint32_t hash_function_count, |
| 25 uint32_t hash_seed_offset); | 25 uint32_t hash_seed_offset); |
| 26 ~BloomFilter(); | 26 ~BloomFilter(); |
| 27 | 27 |
| 28 // Add a single string to the Bloom filter. | 28 // Add a single string to the Bloom filter. |
| 29 void AddString(const std::string& str); | 29 void AddString(const std::string& str); |
| 30 | 30 |
| 31 // Clears all bloom filter bits. |
| 32 void Clear(); |
| 33 |
| 31 // Returns the current value of the Bloom filter's bit array. | 34 // Returns the current value of the Bloom filter's bit array. |
| 32 const ByteVector& bytes() const { return bytes_; }; | 35 const ByteVector& bytes() const { return bytes_; }; |
| 33 | 36 |
| 37 // Sets bytes for testing purposes. |
| 38 void SetBytesForTesting(const ByteVector& bytes); |
| 39 |
| 34 private: | 40 private: |
| 35 // Stores the byte array of the Bloom filter. | 41 // Stores the byte array of the Bloom filter. |
| 36 ByteVector bytes_; | 42 ByteVector bytes_; |
| 37 | 43 |
| 38 // The number of bits to set for each string added. | 44 // The number of bits to set for each string added. |
| 39 uint32_t hash_function_count_; | 45 uint32_t hash_function_count_; |
| 40 | 46 |
| 41 // A number add to a hash function index to get a seed for that hash function. | 47 // A number add to a hash function index to get a seed for that hash function. |
| 42 uint32_t hash_seed_offset_; | 48 uint32_t hash_seed_offset_; |
| 43 | 49 |
| 44 DISALLOW_COPY_AND_ASSIGN(BloomFilter); | 50 DISALLOW_COPY_AND_ASSIGN(BloomFilter); |
| 45 }; | 51 }; |
| 46 | 52 |
| 47 } // namespace rappor | 53 } // namespace rappor |
| 48 | 54 |
| 49 #endif // COMPONENTS_RAPPOR_BLOOM_FILTER_H_ | 55 #endif // COMPONENTS_RAPPOR_BLOOM_FILTER_H_ |
| OLD | NEW |