Class Cache<TKey, TValue>
- Namespace
- AlgorithmsSW
- Assembly
- AlgorithmsSW.dll
Class that caches values for keys.
public class Cache<TKey, TValue>
Type Parameters
TKeyThe type of the keys.
TValueThe type of the values.
- Inheritance
-
Cache<TKey, TValue>
- Inherited Members
- Extension Methods
Constructors
Cache(Func<TKey, TValue>, IComparer<TKey>)
Initializes a new instance of the Cache<TKey, TValue> class.
public Cache(Func<TKey, TValue> valueFactory, IComparer<TKey> comparer)
Parameters
valueFactoryFunc<TKey, TValue>The function to use to create values for keys.
comparerIComparer<TKey>The comparer to use for comparing keys.
Properties
this[TKey]
Retrieves the value associated with the specified key.
public TValue this[TKey key] { get; }
Parameters
keyTKeyThe key whose value to get.
Property Value
- TValue
Remarks
If the key does not exist in the cache, the value is created using the value factory and added to the cache.
Methods
Clear()
Clears the cache.
public void Clear()