Windows Dev Center

Platform::Collections::Map Class

Represents a map, which is a collection of key-value pairs.

template <
   typename K,
   typename V,
   typename C = std::less<K
ref class Map sealed;


The type of the key in the key-value pair.


The type of the value in the key-value pair.


A type that provides a function object that can compare two element values as sort keys to determine their relative order in the Map. By default, std::less<K>.


A compiler generated function that validates the type of K and V and provides a friendly error message if the type cannot be stored in the Map.

Allowed types are:

  • integers

  • interface class ^

  • public ref class^

  • value struct

  • public enum class

Map is basically a wrapper for std::map. It is a C++ concrete implementation of the Windows::Foundation::Collections::IMap<Windows::Foundation::Collections::IKeyValuePair<K,V>> and IObservableMap types that are passed across public Windows Runtime interfaces. If you try to use a Platform::Collections::Map type in a public return value or parameter, compiler error C3986 is raised. You can fix the error by changing the type of the parameter or return value to Windows::Foundation::Collections::IMap<K,V>.

For more information, see Collections (C++/CX).



Map::Map Constructor

Initializes a new instance of the Map class.



Map::Clear Method

Removes all key-value pairs from the current Map object.

Map::First Method

Returns an iterator that specifies the first element in the map.

Map::GetView Method

Returns a read-only view of the current Map; that is, a Platform::Collections::MapView Class.

Map::HasKey Method

Determines whether the current Map contains the specified key.

Map::Insert Method

Adds the specified key-value pair to the current Map object.

Map::Lookup Method

Retrieves the element at the specified key in the current Map object.

Map::Remove Method

Deletes the specified key-value pair from the current Map object.

Map::Size Method

Returns the number of elements in the current Map object.



Map::MapChanged Event event

Occurs when the Map changes.

Header: collection.h

Namespace: Platform::Collections


Other Resources

Platform Namespace
© 2015 Microsoft