IMap<K, V> IMap<K, V> IMap<K, V> IMap<K, V> IMap<K, V> Interface

Definition

Represents an associative collection, also known as a map or a dictionary.

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

public : interface IMap<K, V> : IIterable<IKeyValuePair<K, V>>
struct winrt::Windows::Foundation::Collections::IMap<K, V> : IIterable<IKeyValuePair<K, V>>
public interface IMap<K, V> : IEnumerable<KeyValuePair<K, V>>
Public Interface IMap<K, V> Implements IEnumerable<KeyValuePair<K, V>>
// You can't instantiate an interface directly in JavaScript. You can use objects that implement the interface, however.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.FoundationContract (introduced v1)

Remarks

When programming with .NET, this interface is hidden and developers should use the System.Collections.Generic.IDictionary<TKey,TValue> interface if they want to implement a map/dictionary type. In any case where a Windows Runtime type has implemented IMap;, .NET code can use the APIs of IDictionary<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 Visual C++ component extensions (C++/CX) from a C# or Visual Basic app.

The IMap; interface represents a collection of key-value pairs where a value can be accessed by its associated key. Properties and methods of IMap; support dictionary-type functionality, such as getting the size of the collection, and adding and removing items at specified locations in the collection. Additionally, the GetView method provides a snapshot of the map whose observable state does not change. The snapshot is useful when you need a view of the collection to refer to in subsequent operations that involve IMap;.

Interface inheritance

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

Properties

Size Size Size Size Size

Gets the number of items in the map.

Methods

Clear() Clear() Clear() Clear() Clear()

Removes all items from the map.

GetView() GetView() GetView() GetView() GetView()

Returns an immutable view of the map.

HasKey(K) HasKey(K) HasKey(K) HasKey(K) HasKey(K)

Determines whether the map contains the specified key.

Insert(K, V) Insert(K, V) Insert(K, V) Insert(K, V) Insert(K, V)

Inserts or replaces an item in the map.

Lookup(K) Lookup(K) Lookup(K) Lookup(K) Lookup(K)

Returns the item at the specified key in the map.

Remove(K) Remove(K) Remove(K) Remove(K) Remove(K)

Removes an item from the map.

See Also