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

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: Split Name/Parameters Created 6 years, 10 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,
Alexei Svitkine (slow) 2014/02/05 18:07:01 Nit: 1 param per line; align.
Steven Holte 2014/02/05 22:44:37 Done.
25 uint32_t hash_seed_offset);
Alexei Svitkine (slow) 2014/02/05 18:07:01 Document hash_seed_offset.
Steven Holte 2014/02/05 22:44:37 Done.
26 ~BloomFilter();
27
28 // Add a single string to the Bloom filter.
29 void AddString(const std::string& str);
30
31 // Returns the current value of the Bloom filter's bit array.
32 const ByteVector& bytes() const { return bytes_; };
33
34 // Returns the number of bits set for each string added to the filter.
35 uint32_t hash_function_count() const { return hash_function_count_; };
36
37 private:
38 // Stores the byte array of the Bloom filter.
39 ByteVector bytes_;
40 // The number of bits to set for each string added.
41 uint32_t hash_function_count_;
42 uint32_t hash_seed_offset_;
43
44 DISALLOW_COPY_AND_ASSIGN(BloomFilter);
45 };
46
47 } // namespace rappor
48
49 #endif // COMPONENTS_RAPPOR_BLOOM_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698