Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Represents a read-only view into a map, which is a collection of key-value pairs.
Syntax
template <
typename K,
typename V,
typename C = ::std::less<K>>
ref class MapView sealed;
Parameters
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>.
Remarks
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).
Members
Public Constructors
| Name | Description |
|---|---|
| MapView::MapView | Initializes a new instance of the MapView class. |
Public Methods
| 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. |
Inheritance Hierarchy
MapView
Requirements
Header: collection.h
Namespace: Platform::Collections
MapView::First Method
Returns an iterator that specifies the first element in the map view.
Syntax
virtual Windows::Foundation::Collections::IIterator<
Windows::Foundation::Collections::IKeyValuePair<K, V>^>^ First();
Return Value
An iterator that specifies the first element in the map view.
Remarks
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();.
MapView::HasKey Method
Determines whether the current MapView contains the specified key.
Syntax
bool HasKey(K key);
Parameters
key
The key used to locate the MapView element. The type of key is typename K.
Return Value
true if the key is found; otherwise, false.
MapView::Lookup Method
Retrieves the value of type V that is associated with the specified key of type K.
Syntax
V Lookup(K key);
Parameters
key
The key used to locate an element in the MapView. The type of key is typename K.
Return Value
The value that is paired with the key. The type of the return value is typename V.
MapView::MapView Constructor
Initializes a new instance of the MapView class.
Syntax
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());
Parameters
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.
MapView::Size Method
Returns the number of elements in the current MapView object.
Syntax
virtual property unsigned int Size;
Return Value
The number of elements in the current MapView.
MapView::Split Method
Divides the current MapView object into two MapView objects. This method is non-operational.
Syntax
void Split(
Windows::Foundation::Collections::IMapView<
K, V>^ * firstPartition,
Windows::Foundation::Collections::IMapView<
K, V>^ * secondPartition);
Parameters
firstPartition
The first part of the original MapView object.
secondPartition
The second part of the original MapView object.
Remarks
This method is not operational; it does nothing.