OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 #include "base/logging.h" | |
6 #include "components/rappor/bytevector.h" | |
7 | |
8 namespace rappor { | |
9 | |
10 ByteVector::ByteVector(size_t bytes_size) : std::vector<uint8_t>(bytes_size) {} | |
11 | |
12 ByteVector::ByteVector(const std::vector<uint8_t>& v) | |
13 : std::vector<uint8_t>(v) {} | |
14 | |
15 ByteVector::ByteVector(const char* bytes, int size) | |
16 : std::vector<uint8_t>(bytes, bytes + size) {} | |
17 | |
18 ByteVector ByteVector::operator&(ByteVector rhs) const { | |
19 DCHECK(size() == rhs.size()); | |
jwd
2013/12/16 17:04:03
I would document the size equality restriction in
Steven Holte
2013/12/16 23:02:16
Done.
| |
20 ByteVector output(*this); | |
21 for (size_t i = 0, len = rhs.size(); i < len; i++) { | |
22 output[i] = output[i] & rhs[i]; | |
23 } | |
24 return output; | |
25 } | |
26 | |
27 ByteVector ByteVector::operator|(ByteVector rhs) const { | |
28 DCHECK(size() == rhs.size()); | |
jwd
2013/12/16 17:04:03
Dito
Steven Holte
2013/12/16 23:02:16
Done.
| |
29 ByteVector output(*this); | |
30 for (size_t i = 0, len = rhs.size(); i < len; i++) { | |
31 output[i] = output[i] | rhs[i]; | |
32 } | |
33 return output; | |
34 } | |
35 | |
36 ByteVector ByteVector::operator~() const { | |
37 ByteVector output(size()); | |
38 for (size_t i = 0, len = size(); i < len; i++) { | |
39 output[i] = ~at(i); | |
40 } | |
41 return output; | |
42 } | |
43 | |
44 } // namespace rappor | |
OLD | NEW |