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 MOJO_PUBLIC_CPP_BINDINGS_MAP_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_MAP_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_MAP_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_MAP_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "mojo/public/cpp/bindings/lib/map_internal.h" | 10 #include "mojo/public/cpp/bindings/lib/map_internal.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void insert(KeyForwardType key, ValueForwardType value) { | 81 void insert(KeyForwardType key, ValueForwardType value) { |
82 is_null_ = false; | 82 is_null_ = false; |
83 Traits::Insert(&map_, key, value); | 83 Traits::Insert(&map_, key, value); |
84 } | 84 } |
85 | 85 |
86 ValueRefType at(KeyForwardType key) { return Traits::at(&map_, key); } | 86 ValueRefType at(KeyForwardType key) { return Traits::at(&map_, key); } |
87 ValueConstRefType at(KeyForwardType key) const { | 87 ValueConstRefType at(KeyForwardType key) const { |
88 return Traits::at(&map_, key); | 88 return Traits::at(&map_, key); |
89 } | 89 } |
90 | 90 |
| 91 ValueRefType operator[](KeyForwardType key) { |
| 92 is_null_ = false; |
| 93 return Traits::GetOrInsert(&map_, key); |
| 94 } |
| 95 |
91 void Swap(Map<Key, Value>* other) { | 96 void Swap(Map<Key, Value>* other) { |
92 std::swap(is_null_, other->is_null_); | 97 std::swap(is_null_, other->is_null_); |
93 map_.swap(other->map_); | 98 map_.swap(other->map_); |
94 } | 99 } |
95 void Swap(std::map<Key, Value>* other) { | 100 void Swap(std::map<Key, Value>* other) { |
96 is_null_ = false; | 101 is_null_ = false; |
97 map_.swap(*other); | 102 map_.swap(*other); |
98 } | 103 } |
99 | 104 |
100 // This moves all values in the map to a set of parallel arrays. This action | 105 // This moves all values in the map to a set of parallel arrays. This action |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 TypeConverter<STLValue, MojoValue>::Convert(it.GetValue()))); | 221 TypeConverter<STLValue, MojoValue>::Convert(it.GetValue()))); |
217 } | 222 } |
218 } | 223 } |
219 return result; | 224 return result; |
220 } | 225 } |
221 }; | 226 }; |
222 | 227 |
223 } // namespace mojo | 228 } // namespace mojo |
224 | 229 |
225 #endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_H_ | 230 #endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_H_ |
OLD | NEW |