• Home
  • Raw
  • Download

Lines Matching full:map

9 #include <map>
22 // A move-only map that can handle move-only values. Map has the following
24 // - The map itself can be null, and this is distinct from empty.
29 // - Values of move-only types will be moved into the Map when they are added
32 class Map {
37 // Map keys cannot be move only classes.
39 "Map keys cannot be move only types.");
41 using Iterator = typename std::map<Key, Value>::iterator;
42 using ConstIterator = typename std::map<Key, Value>::const_iterator;
44 // Constructs an empty map.
45 Map() : is_null_(false) {} in Map() function
46 // Constructs a null map.
47 Map(std::nullptr_t null_pointer) : is_null_(true) {} in Map() function
49 // Constructs a non-null Map containing the specified |keys| mapped to the
51 Map(mojo::Array<Key> keys, mojo::Array<Value> values) : is_null_(false) { in Map() function
57 ~Map() {} in ~Map()
59 Map(std::map<Key, Value>&& other) : map_(std::move(other)), is_null_(false) {} in Map() function
60 Map(Map&& other) : is_null_(true) { Take(&other); } in Map() function
62 Map& operator=(std::map<Key, Value>&& other) {
67 Map& operator=(Map&& other) {
72 Map& operator=(std::nullptr_t null_pointer) {
78 // Copies the contents of some other type of map into a new Map using a
79 // TypeConverter. A TypeConverter for std::map to Map is defined below.
81 static Map From(const U& other) { in From()
82 return TypeConverter<Map, U>::Convert(other); in From()
85 // Copies the contents of the Map into some other type of map. A TypeConverter
86 // for Map to std::map is defined below.
89 return TypeConverter<U, Map>::Convert(*this); in To()
92 // Indicates whether the map is null (which is distinct from empty).
95 // Indicates whether the map is empty (which is distinct from null).
98 // Indicates the number of keys in the map, which will be zero if the map is
102 // Inserts a key-value pair into the map. Like std::map, this does not insert
103 // |value| if |key| is already a member of the map.
114 // crashing the process if the key is not present in the map.
119 // creating a new entry if the key is not already present in the map. A
128 // Sets the map to empty (even if previously it was null).
134 // Returns a const reference to the std::map managed by this class. If this
135 // object is null, the return value will be an empty map.
136 const std::map<Key, Value>& storage() const { return map_; } in storage()
138 // Passes the underlying storage and resets this map to null.
139 std::map<Key, Value> PassStorage() { in PassStorage()
144 operator const std::map<Key, Value>&() const { return map_; }
146 // Swaps the contents of this Map with another Map of the same type (including
148 void Swap(Map<Key, Value>* other) { in Swap()
153 // Swaps the contents of this Map with an std::map containing keys and values
154 // of the same type. Since std::map cannot represent the null state, the
155 // std::map will be empty if Map is null. The Map will always be left in a
157 void Swap(std::map<Key, Value>* other) { in Swap()
162 // Removes all contents from the Map and places them into parallel key/value
165 // case they will be moved. Either way, the Map will be left in a null state.
184 // Returns a new Map that contains a copy of the contents of this map. If the
191 Map Clone() const { in Clone()
192 Map result; in Clone()
201 // Indicates whether the contents of this map are equal to those of another
202 // Map (including nullness). If the key/value type defines an Equals() method,
204 bool Equals(const Map& other) const { in Equals()
222 // Provide read-only iteration over map members in a way similar to STL
236 typedef std::map<Key, Value> Map::*Testable;
239 // The Map may be used in boolean expressions to determine if it is non-null,
242 operator Testable() const { return is_null_ ? 0 : &Map::map_; } in Testable()
245 // Forbid the == and != operators explicitly, otherwise Map will be converted
248 bool operator==(const Map<T, U>& other) const = delete;
250 bool operator!=(const Map<T, U>& other) const = delete;
252 void Take(Map* other) { in Take()
257 std::map<Key, Value> map_;
260 DISALLOW_COPY_AND_ASSIGN(Map);
263 // Copies the contents of an std::map to a new Map, optionally changing the
269 struct TypeConverter<Map<MojoKey, MojoValue>, std::map<STLKey, STLValue>> {
270 static Map<MojoKey, MojoValue> Convert(
271 const std::map<STLKey, STLValue>& input) {
272 Map<MojoKey, MojoValue> result;
281 // Copies the contents of a Map to an std::map, optionally changing the types of
287 struct TypeConverter<std::map<STLKey, STLValue>, Map<MojoKey, MojoValue>> {
288 static std::map<STLKey, STLValue> Convert(
289 const Map<MojoKey, MojoValue>& input) {
290 std::map<STLKey, STLValue> result;