CachedObjectManagerByMaximumNumberOfItemsTKey, TValue Class |
Manages a bunch of cached objects. The cached object are accessed by a key. In this instance more than one object with the same key can be stored, but it is presumed that all objects which
are stored under the same key are considered equal.
Usage: Try to take out a cached object with
TryTake(TKey, TValue). If no such object exists, create a new one. After usage of the object, put it back with
Add(TKey, TValue).
If after adding an object more than the allowed number of objects exists, the object which is used the least will be removed from that instance.
The methods in this instance are thread safe.
Inheritance HierarchySystemObject Altaxo.CollectionsCachedObjectManagerByMaximumNumberOfItemsTKey, TValue Namespace: Altaxo.CollectionsAssembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3261.0 (4.8.3261.0)
Syntaxpublic sealed class CachedObjectManagerByMaximumNumberOfItems<TKey, TValue>
Type Parameters
- TKey
- The type of the key that characterizes the value.
- TValue
- The type of the value.
The CachedObjectManagerByMaximumNumberOfItemsTKey, TValue type exposes the following members.
Constructors
Methods | Name | Description |
---|
 | Add |
Adds an object under the specified key.
|
 | Clear |
Removes all items in the collection. If the values implement IDisposable, the items are disposed.
|
 | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
 | GetHashCode | Serves as the default hash function. (Inherited from Object) |
 | GetType | Gets the Type of the current instance. (Inherited from Object) |
 | ToString | Returns a string that represents the current object. (Inherited from Object) |
 | TryTake |
Try to take a stored object from this collection.
If successfull, this function will return any object that was stored under the given key.
|
Top
Remarks
Two collections are neccessary to store the items: The values are stored in a doubly linked list as KeyValuePairs together with their key.
The first item in the doubly linked list is the most recently added item. The last item in the doubly linked list is the least used item.
To have fast access to the items by key, a dictionary can be accessed by those keys. The values of this dictionary are HashSets
of LinkedListNodes, these LinkedListNodes that are members of the doubly linked list, and whose values are associated with the key.
See Also