OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef EXTENSIONS_COMMON_VALUE_COUNTER_H_ | 5 #ifndef EXTENSIONS_COMMON_VALUE_COUNTER_H_ |
6 #define EXTENSIONS_COMMON_VALUE_COUNTER_H_ | 6 #define EXTENSIONS_COMMON_VALUE_COUNTER_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class Value; | 14 class Value; |
15 } | 15 } |
16 | 16 |
17 namespace extensions { | 17 namespace extensions { |
18 | 18 |
19 // Keeps a running count of Values, like map<Value, int>. Adding/removing | 19 // Keeps a running count of Values, like map<Value, int>. Adding/removing |
20 // values increments/decrements the count associated with a given Value. | 20 // values increments/decrements the count associated with a given Value. |
21 // | 21 // |
(...skipping 13 matching lines...) Expand all Loading... |
35 // Removes |value| from the set, and returns true if it removed the last | 35 // Removes |value| from the set, and returns true if it removed the last |
36 // value equal to |value|. If there are more equal values, or if there | 36 // value equal to |value|. If there are more equal values, or if there |
37 // weren't any in the first place, returns false. | 37 // weren't any in the first place, returns false. |
38 bool Remove(const base::Value& value); | 38 bool Remove(const base::Value& value); |
39 | 39 |
40 // Returns true if there are no values of any type being counted. | 40 // Returns true if there are no values of any type being counted. |
41 bool is_empty() const { return entries_.empty(); } | 41 bool is_empty() const { return entries_.empty(); } |
42 | 42 |
43 private: | 43 private: |
44 struct Entry; | 44 struct Entry; |
45 std::vector<scoped_ptr<Entry>> entries_; | 45 std::vector<std::unique_ptr<Entry>> entries_; |
46 | 46 |
47 DISALLOW_COPY_AND_ASSIGN(ValueCounter); | 47 DISALLOW_COPY_AND_ASSIGN(ValueCounter); |
48 }; | 48 }; |
49 | 49 |
50 } // namespace extensions | 50 } // namespace extensions |
51 | 51 |
52 #endif // EXTENSIONS_COMMON_VALUE_COUNTER_H_ | 52 #endif // EXTENSIONS_COMMON_VALUE_COUNTER_H_ |
OLD | NEW |