Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: components/rappor/bloom_filter.h

Issue 49753002: RAPPOR implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cohorts Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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.
23 // Currently, |hash_function_count| must be at most 4.
24 BloomFilter(uint32_t bytes_size, uint32_t hash_function_count,
25 uint32_t hash_seed_offset);
Alexei Svitkine (slow) 2014/01/24 22:09:03 Nit: 1 param per line and align. Also, document h
26 ~BloomFilter();
27
28 // Add a single string to the Bloom filter.
29 void AddString(const std::string& str);
30
31 // Adds multiple strings to the Bloom filter.
32 void AddStrings(const std::vector<std::string>& strings);
33
34 // Returns the current value of the Bloom filter's bit array.
35 const ByteVector& bytes() const { return bytes_; };
36
37 // Returns the number of bits set for each string added to the filter.
38 uint32_t hash_function_count() const { return hash_function_count_; };
39
40 private:
41 // Stores the byte array of the Bloom filter.
42 ByteVector bytes_;
43 // The number of bits to set for each string added.
44 uint32_t hash_function_count_;
45 uint32_t hash_seed_offset_;
46
47 DISALLOW_COPY_AND_ASSIGN(BloomFilter);
48 };
49
50 } // namespace rappor
51
52 #endif // COMPONENTS_RAPPOR_BLOOM_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698