| title | Platform::Collections::MapView Class | Microsoft Docs | ||||||
|---|---|---|---|---|---|---|---|
| ms.custom | |||||||
| ms.date | 12/30/2016 | ||||||
| ms.technology | cpp-windows | ||||||
| ms.reviewer | |||||||
| ms.suite | |||||||
| ms.tgt_pltfrm | |||||||
| ms.topic | language-reference | ||||||
| f1_keywords |
|
||||||
| dev_langs |
|
||||||
| helpviewer_keywords |
|
||||||
| ms.assetid | 9577dde7-f599-43c6-b1e4-7d653706fd62 | ||||||
| caps.latest.revision | 9 | ||||||
| author | ghogen | ||||||
| ms.author | ghogen | ||||||
| manager | ghogen |
Represents a read-only view into a map, which is a collection of key-value pairs.
template <
typename K,
typename V,
typename C = ::std::less<K>>
ref class MapView sealed;
K
The type of the key in the key-value pair.
V
The type of the value in the key-value pair.
C
A type that provides a function object that can compare two element values as sort keys to determine their relative order in the MapView. By default, std::less<K>.
MapView is a concrete C++ implementation of the Windows::Foundation::Collections::IMapView <K,V> interface that is passed across the application binary interface (ABI). For more information, see Collections (C++/CX).
| Name | Description |
|---|---|
| MapView::MapView | Initializes a new instance of the MapView class. |
| Name | Description |
|---|---|
| MapView::First | Returns an iterator that is initialized to the first element in the map view. |
| MapView::HasKey | Determines whether the current MapView contains the specified key. |
| MapView::Lookup | Retrieves the element at the specified key in the current MapView object. |
| MapView::Size | Returns the number of elements in the current MapView object. |
| MapView::Split | Splits an original MapView object into two MapView objects. |
MapView
Header: collection.h
Namespace: Platform::Collections
Returns an iterator that specifies the first element in the map view.
virtual Windows::Foundation::Collections::IIterator<
Windows::Foundation::Collections::IKeyValuePair<K, V>^>^ First();
An iterator that specifies the first element in the map view.
A convenient way to hold the iterator returned by First() is to assign the return value to a variable that is declared with the auto type deduction keyword. For example, auto x = myMapView->First();.
Determines whether the current MapView contains the specified key.
bool HasKey(K key);
key
The key used to locate the MapView element. The type of key is typename K.
true if the key is found; otherwise, false.
Retrieves the value of type V that is associated with the specified key of type K.
V Lookup(K key);
key
The key used to locate an element in the MapView. The type of key is typename K.
The value that is paired with the key. The type of the return value is typename V.
Initializes a new instance of the MapView class.
explicit MapView(const C& comp = C());
explicit MapView(const ::std::map<K, V, C>& m);
explicit MapView(std::map<K, V, C>&& m);
template <typename InIt> MapView(
InIt first,
InIt last,
const C& comp = C());
MapView(
::std::initializer_list<std::pair<const K, V>> il,
const C& comp = C()); InIt
The typename of the current MapView.
comp
A function object that can compare two element values as sort keys to determine their relative order in the MapView.
m
A reference or Lvalues and Rvalues to a map Class that is used to initialize the current MapView.
first
The input iterator of the first element in a range of elements used to initialize the current MapView.
last
The input iterator of the first element after a range of elements used to initialize the current MapView.
il
A std::initializer_list<std::pair<K,V>> whose elements will be inserted into the MapView.
Returns the number of elements in the current MapView object.
virtual property unsigned int Size; The number of elements in the current MapView.
Divides the current MapView object into two MapView objects. This method is non-operational.
void Split(
Windows::Foundation::Collections::IMapView<
K, V>^ * firstPartition,
Windows::Foundation::Collections::IMapView<
K, V>^ * secondPartition);
firstPartition
The first part of the original MapView object.
secondPartition
The second part of the original MapView object.
This method is not operational; it does nothing.