OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/metrics/sample_vector.h" | 5 #include "base/metrics/sample_vector.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/bucket_ranges.h" | 8 #include "base/metrics/bucket_ranges.h" |
9 | 9 |
10 using std::vector; | 10 using std::vector; |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 Count SampleVector::TotalCount() const { | 37 Count SampleVector::TotalCount() const { |
38 Count count = 0; | 38 Count count = 0; |
39 for (size_t i = 0; i < counts_.size(); i++) { | 39 for (size_t i = 0; i < counts_.size(); i++) { |
40 count += counts_[i]; | 40 count += counts_[i]; |
41 } | 41 } |
42 return count; | 42 return count; |
43 } | 43 } |
44 | 44 |
45 Count SampleVector::GetCountAtIndex(size_t bucket_index) const { | 45 Count SampleVector::GetCountAtIndex(size_t bucket_index) const { |
46 DCHECK(bucket_index >= 0 && bucket_index < counts_.size()); | 46 DCHECK(bucket_index < counts_.size()); |
47 return counts_[bucket_index]; | 47 return counts_[bucket_index]; |
48 } | 48 } |
49 | 49 |
50 scoped_ptr<SampleCountIterator> SampleVector::Iterator() const { | 50 scoped_ptr<SampleCountIterator> SampleVector::Iterator() const { |
51 return scoped_ptr<SampleCountIterator>( | 51 return scoped_ptr<SampleCountIterator>( |
52 new SampleVectorIterator(&counts_, bucket_ranges_)); | 52 new SampleVectorIterator(&counts_, bucket_ranges_)); |
53 } | 53 } |
54 | 54 |
55 bool SampleVector::AddSubtractImpl(SampleCountIterator* iter, | 55 bool SampleVector::AddSubtractImpl(SampleCountIterator* iter, |
56 HistogramSamples::Operator op) { | 56 HistogramSamples::Operator op) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 return; | 152 return; |
153 | 153 |
154 while (index_ < counts_->size()) { | 154 while (index_ < counts_->size()) { |
155 if ((*counts_)[index_] != 0) | 155 if ((*counts_)[index_] != 0) |
156 return; | 156 return; |
157 index_++; | 157 index_++; |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 } // namespace base | 161 } // namespace base |
OLD | NEW |