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

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: RapporMetric Created 6 years, 12 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 (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.
19 class BloomFilter {
20 public:
21 BloomFilter(uint32_t bytes_size, uint32_t hash_count);
22 ~BloomFilter();
23
24 void AddString(const std::string& str);
25 void AddStrings(const std::vector<std::string>& strings);
26
27 // Returns the current value of the bloom filter's bit array.
28 const ByteVector& bytes() const {
29 return bytes_;
Alexei Svitkine (slow) 2013/12/24 16:59:30 Nit: This can go on the same line as above. Same f
Steven Holte 2014/01/04 00:12:54 Done.
30 };
31 // Returns the number of bits set for each string added to the filter.
32 uint32_t hash_count() const {
33 return hash_count_;
34 };
35
36 private:
37 // Stores the bit array of the bloom filter.
38 ByteVector bytes_;
39 // The number of bits to set for each string added.
40 uint32_t hash_count_;
41
42 DISALLOW_COPY_AND_ASSIGN(BloomFilter);
43 };
44
45 } // namespace rappor
46
47 #endif // COMPONENTS_RAPPOR_BLOOM_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698