Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 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. | |
|
Ilya Sherman
2014/01/10 11:00:32
nit: "bloom filter" -> "Bloom filter", since "Bloo
Steven Holte
2014/01/14 00:47:54
Done.
| |
| 19 class BloomFilter { | |
|
Ilya Sherman
2014/01/10 11:00:32
Hmm, I'm going to be we already have a Bloom filte
Steven Holte
2014/01/14 00:47:54
Yes. Extracting safebrowsing's bloom filter looks
| |
| 20 public: | |
| 21 BloomFilter(uint32_t bytes_size, uint32_t hash_count); | |
|
Ilya Sherman
2014/01/10 11:00:32
nit: Please document the parameters, including the
Steven Holte
2014/01/14 00:47:54
Done.
| |
| 22 ~BloomFilter(); | |
| 23 | |
| 24 void AddString(const std::string& str); | |
| 25 void AddStrings(const std::vector<std::string>& strings); | |
|
Ilya Sherman
2014/01/10 11:00:32
nit: Please document these methods (fine to be ver
Steven Holte
2014/01/14 00:47:54
Done.
| |
| 26 | |
| 27 // Returns the current value of the bloom filter's bit array. | |
| 28 const ByteVector& bytes() const { return bytes_; }; | |
| 29 // Returns the number of bits set for each string added to the filter. | |
| 30 uint32_t hash_count() const { return hash_count_; }; | |
| 31 | |
| 32 private: | |
| 33 // Stores the bit array of the bloom filter. | |
|
Ilya Sherman
2014/01/10 11:00:32
Optional nit: "bit array" -> "byte array"?
Steven Holte
2014/01/14 00:47:54
Done.
| |
| 34 ByteVector bytes_; | |
| 35 // The number of bits to set for each string added. | |
| 36 uint32_t hash_count_; | |
|
Ilya Sherman
2014/01/10 11:00:32
nit: This might be more clear if named something l
Steven Holte
2014/01/14 00:47:54
Done.
| |
| 37 | |
| 38 DISALLOW_COPY_AND_ASSIGN(BloomFilter); | |
| 39 }; | |
| 40 | |
| 41 } // namespace rappor | |
| 42 | |
| 43 #endif // COMPONENTS_RAPPOR_BLOOM_FILTER_H_ | |
| OLD | NEW |