Class Cache<TKey, TValue>
A base class for cache data structures.
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Flame.Collections
Assembly: Flame.dll
Syntax
public abstract class Cache<TKey, TValue>
Type Parameters
Name | Description |
---|---|
TKey | |
TValue |
Methods
| Improve this Doc View SourceContainsKey(TKey)
Tests if this cache contains a particular key.
Declaration
public virtual bool ContainsKey(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key to look for. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Get(TKey, Func<TKey, TValue>)
Queries the cache for the value with a particular key. If that value cannot be found, the key is recomputed.
Declaration
public virtual TValue Get(TKey key, Func<TKey, TValue> createValue)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the value to query. |
System.Func<TKey, TValue> | createValue | A callback that creates the value for the key, in case the key was not in the cache. |
Returns
Type | Description |
---|---|
TValue | The value for the key. |
Insert(TKey, TValue)
Inserts a new key-value pair into this cache, or overwrites the value for an existing key.
Declaration
public abstract void Insert(TKey key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The cached value's key. |
TValue | value | The value to cache. |
TryGet(TKey, out TValue)
Tries to query the cache for the value with a particular key.
Declaration
public abstract bool TryGet(TKey key, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the value to query. |
TValue | value | A cached value, if any. |
Returns
Type | Description |
---|---|
System.Boolean |
|