Udostępnij za pośrednictwem


IMapView<K,V> Interface

Definition

Represents an immutable view into a map.

.NET This interface appears as System.Collections.Generic.IReadOnlyDictionary<TKey,TValue> due to .NET language projection. In any case where a Windows Runtime type has implemented IMapView<K,V>, .NET code can use the APIs of IReadOnlyDictionary<TKey,TValue> instead.

public interface class IMapView : IIterable<IKeyValuePair<K, V> ^>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(3833646656, 41784, 19162, 173, 207, 39, 34, 114, 228, 140, 185)]
template <typename K, typename V>
struct IMapView : IIterable<IKeyValuePair<K, V>>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
[Windows.Foundation.Metadata.Guid(3833646656, 41784, 19162, 173, 207, 39, 34, 114, 228, 140, 185)]
public interface IReadOnlyDictionary<K,V> : IEnumerable<KeyValuePair<K,V>>
Public Interface IReadOnlyDictionary(Of K, V)
Implements IEnumerable(Of KeyValuePair(Of K, V))

Type Parameters

K
V
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.FoundationContract (introduced in v1.0)

Remarks

When programming with .NET, this interface is hidden and developers should use the System.Collections.Generic.IReadOnlyDictionary<TKey,TValue> interface if they want to implement a read-only map/dictionary type. In any case where a Windows Runtime type has implemented IMapView<K,V>, .NET code can use the APIs of IReadOnlyDictionary<TKey,TValue> instead. This includes all the existing Windows Runtime API and also scenarios such as using the APIs of Windows Runtime components originally implemented in C++ from a C# or Visual Basic app.

The IMapView<K,V> interface represents a collection of key-value pairs where a value can be accessed by its associated key. Properties and methods of IMapView<K,V> support dictionary-type functionality, such as getting the size of the collection, or lookups, but don't support adding or removing items because the map is read-only.

C++/WinRT extension functions

Note

Extension functions exist on the C++/WinRT projection types for certain Windows Runtime APIs. For example, winrt::Windows::Foundation::IAsyncAction is the C++/WinRT projection type for IAsyncAction. The extension functions aren't part of the application binary interface (ABI) surface of the actual Windows Runtime types, so they're not listed as members of the Windows Runtime APIs. But you can call them from within any C++/WinRT project. See C++/WinRT functions that extend Windows Runtime APIs.

auto begin() const;

Returns an iterator to the first key-value pair of the collection, for use in C++ algorithms such as range-based for loops.

auto end() const;

Returns an iterator to one past the last key-value pair of the collection, for use in C++ algorithms such as range-based for loops.

auto TryLookup(param_type<K> const& key) const;

Tries to look up an element in the map with the key key. For reference types, returns the value if found, or nullptr if not found. For value types, returns a std::optional<V>, which holds the value if found, or has no value if not found.

Interface inheritance

IMapView inherits IIterable, using an IKeyValuePair constraint. Types that implement IMapView also implement the interface members of IKeyValuePair, with an IKeyValuePair type constraint. Similarly, if you're using .NET, there is support for IEnumerable;T>, with its constraint type as a KeyValuePair that uses the same key and value types as does the IReadOnlyDictionary<TKey,TValue> implementation.

Properties

Size

Gets the number of elements in the map.

Methods

HasKey(K)

Determines whether the map view contains the specified key.

Lookup(K)

Returns the item at the specified key in the map view.

Split(IMapView<K,V>, IMapView<K,V>)

Splits the map view into two views.

Applies to

See also