C

Mapper<K, V>

An IMapper<K, V> implementation backed by an IMap<TKey, TValue>.
ImplementsInheritance Hierarchy

Remarks

A defaultValue can be set that is returned for keys that don't have an explicit value set.

It is legal to use null as key, which can be assigned a value just like other keys.

Type Parameters

K

V

See Also

Developer's Guide

Members

No filters for this type

Constructors

Creates an instance using a HashMap<K, V> as the backing store.
The value for the null item is stored separately.

Parameters

defaultValue?: V
The value to return if no specific value has been set for a given key.
Creates an instance using the provided HashMap<K, V> as the backing store.
The value for the null item is stored separately.

Parameters

dictionary: any
The IMap<TKey, TValue> to use as backing store.
defaultValue?: V
The value to return if no specific value has been set for a given key.

Properties

Gets or sets the default value to return if no specific value has been set for a given key.
Gets an enumerable over all entries in this (dictionary-based) mapper.
readonlyfinal

Methods

Calls clear on the backing implementation.
final
Removes the mapping of the given key.
final

Parameters

key: K
The key of the mapping.
Gets the value for a given key in the mapping.

Setting a value for an already existing key overwrites the previous value.

It depends on the specific implementation of the mapper whether a mapping can be removed. If an implementation provides a way to remove a mapping, that should be preferred over setting a null value. For example, Mapper<K, V> provides the delete method.

Parameters

key: K
The key of the mapping.

Return Value

V
The value.

Implements

IMapper.get
Sets the value for a given key in the mapping.

Setting a value for an already existing key overwrites the previous value.

It depends on the specific implementation of the mapper whether a mapping can be removed. If an implementation provides a way to remove a mapping, that should be preferred over setting a null value. For example, Mapper<K, V> provides the delete method.

Parameters

key: K
The key of the mapping.
value: V
The value.

Implements

IMapper.set