KGy SOFT

CacheTKey, TValue Constructor (IEqualityComparerTKey)

KGy SOFT Core Libraries Help

Namespace:  KGySoft.Collections
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.0.0
Syntax

public Cache(
	IEqualityComparer<TKey> comparer
)

Parameters

comparer
Type: System.Collections.GenericIEqualityComparerTKey
The IEqualityComparerT implementation to use when comparing keys. When , EnumComparer<TEnum>.Comparer will be used for enum key types, and EqualityComparer<T>.Default for other types.
Remarks

Every key in a CacheTKey, TValue must be unique according to the specified comparer.

When CacheTKey, TValue is full (that is, when Count reaches Capacity) and a new element is about to be stored, then an element will be dropped out from the cache. The strategy is controlled by Behavior property.

This constructor does not specify an item loader so you have to add elements manually to this CacheTKey, TValue instance. In this case the CacheTKey, TValue can be used similarly to a DictionaryTKey, TValue: before getting an element, its existence must be checked by ContainsKey or TryGetValue methods, though Capacity is still maintained based on the strategy specified in the Behavior property.

See Also

Reference