OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef CC_BASE_SCOPED_PTR_HASH_MAP_H_ | 5 #ifndef CC_BASE_SCOPED_PTR_HASH_MAP_H_ |
6 #define CC_BASE_SCOPED_PTR_HASH_MAP_H_ | 6 #define CC_BASE_SCOPED_PTR_HASH_MAP_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 typedef base::hash_map<Key, Value*> Container; | 24 typedef base::hash_map<Key, Value*> Container; |
25 | 25 |
26 public: | 26 public: |
27 typedef typename Container::iterator iterator; | 27 typedef typename Container::iterator iterator; |
28 typedef typename Container::const_iterator const_iterator; | 28 typedef typename Container::const_iterator const_iterator; |
29 | 29 |
30 ScopedPtrHashMap() {} | 30 ScopedPtrHashMap() {} |
31 | 31 |
32 ~ScopedPtrHashMap() { clear(); } | 32 ~ScopedPtrHashMap() { clear(); } |
33 | 33 |
34 void swap(ScopedPtrHashMap<Key, Value*>& other) { | 34 void swap(ScopedPtrHashMap<Key, Value>& other) { |
35 data_.swap(other.data_); | 35 data_.swap(other.data_); |
36 } | 36 } |
37 | 37 |
38 std::pair<iterator, bool> insert( | 38 std::pair<iterator, bool> insert( |
39 std::pair<Key, const scoped_ptr<Value> > pair) { | 39 std::pair<Key, const scoped_ptr<Value> > pair) { |
40 return data_.insert( | 40 return data_.insert( |
41 std::pair<Key, Value*>(pair.first, pair.second.release())); | 41 std::pair<Key, Value*>(pair.first, pair.second.release())); |
42 } | 42 } |
43 | 43 |
44 // Replaces value but not key if key is already present. | 44 // Replaces value but not key if key is already present. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 private: | 149 private: |
150 Container data_; | 150 Container data_; |
151 | 151 |
152 DISALLOW_COPY_AND_ASSIGN(ScopedPtrHashMap); | 152 DISALLOW_COPY_AND_ASSIGN(ScopedPtrHashMap); |
153 }; | 153 }; |
154 | 154 |
155 } // namespace cc | 155 } // namespace cc |
156 | 156 |
157 #endif // CC_BASE_SCOPED_PTR_HASH_MAP_H_ | 157 #endif // CC_BASE_SCOPED_PTR_HASH_MAP_H_ |
OLD | NEW |