Class Cache<TKey, TValue>
- Namespace
- AlgorithmsSW
- Assembly
- AlgorithmsSW.dll
Class that caches values for keys.
public class Cache<TKey, TValue>
Type Parameters
TKey
The type of the keys.
TValue
The 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
valueFactory
Func<TKey, TValue>The function to use to create values for keys.
comparer
IComparer<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
key
TKeyThe 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()