Platform::Collections::UnorderedMapView Class

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::equal_to<K>>  
ref class UnorderedMapView 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 key values for equality. By default, std::equal_to<K>

Remarks

UnorderedMapView 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
UnorderedMapView::UnorderedMapView Initializes a new instance of the UnorderedMapView class.

Public Methods

Name Description
UnorderedMapView::First Returns an iterator that is initialized to the first element in the map view.
UnorderedMapView::HasKey Determines whether the current UnorderedMapView contains the specified key.
UnorderedMapView::Lookup Retrieves the element at the specified key in the current UnorderedMapView object.
UnorderedMapView::Size Returns the number of elements in the current UnorderedMapView object.
UnorderedMapView::Split Splits an original UnorderedMapView object into two UnorderedMapView objects.

Inheritance Hierarchy

UnorderedMapView

Requirements

Header: collection.h

Namespace: Platform::Collections

UnorderedMapView::First Method

Returns an iterator that specifies the first Windows::Foundation::Collections::IKeyValuePair<K,V> element in the unordered map.

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();.

UnorderedMapView::HasKey Method

Determines whether the current UnorderedMap contains the specified key.

Syntax

bool HasKey(K key);  

Parameters

key
The key used to locate the element. The type of key is typename K.

Return Value

true if the key is found; otherwise, false.

UnorderedMapView::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 UnorderedMapView. 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.

UnorderedMapView::Size Method

Returns the number of Windows::Foundation::Collections::IKeyValuePair<K,V> elements in the UnorderedMapView.

Syntax

virtual property unsigned int Size;  

Return Value

The number of elements in the Unordered MapView.

UnorderedMapView::Split Method

Divides the current UnorderedMapView object into two UnorderedMapView 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 UnorderedMapView object.

secondPartition
The second part of the original UnorderedMapView object.

Remarks

This method is not operational; it does nothing.

UnorderedMapView::UnorderedMapView Constructor

Initializes a new instance of the UnorderedMapView class.

Syntax


UnorderedMapView();    
explicit UnorderedMapView(size_t n);   
UnorderedMapView(size_t n, const H& h);   
UnorderedMapView(size_t n, const H& h, const P& p);  

explicit UnorderedMapView(  
    const std::unordered_map<K, V, H, P>& m);  
explicit UnorderedMapView(  
    std::unordered_map<K, V, H, P>&& m);  

template <typename InIt> UnorderedMapView(InIt first, InIt last );  
template <typename InIt> UnorderedMapView(InIt first, InIt last, size_t n );  

template <typename InIt> UnorderedMapView(  
    InIt first,  
    InIt last,  
    size_t n,  
    const H& h );  

template <typename InIt> UnorderedMapView(  
    InIt first,  
    InIt last,  
    size_t n,  
    const H& h,  
    const P& p );  

UnorderedMapView(std::initializer_list<std::pair<const K, V>);  

UnorderedMapView(std::initializer_list< std::pair<const K, V>> il, size_t n   

UnorderedMapView(  
    std::initializer_list< std::pair<const K, V>> il,  
    size_t n,  
    const H& h);  

UnorderedMapView(  
    std::initializer_list< std::pair<const K, V>> il,  
    size_t n,  
    const H& h,  
    const P& p );  

Parameters

n
The number of elements to preallocate space for.

InIt
The typename of the UnorderedMapView.

H
A function object that can a hash value for a key. Defaults to std::hash<K> for the types that std::hash supports.

P
A type that provides a function object that can compare two keys to determine their equality. Defaults to std::equal_to<K>.

m
A reference or Lvalues and Rvalues to a std::unordered_map that is used to initialize the UnorderedMapView.

first
The input iterator of the first element in a range of elements used to initialize the UnorderedMapView.

last
The input iterator of the first element after a range of elements used to initialize the UnorderedMapView.

See Also

Platform::Collections Namespace
Windows::Foundation::IMapView