Click or drag to resize

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 Hierarchy
SystemObject
  Altaxo.CollectionsCachedObjectManagerByMaximumNumberOfItemsTKey, TValue

Namespace: Altaxo.Collections
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax
C#
public 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
 NameDescription
Public methodCachedObjectManagerByMaximumNumberOfItemsTKey, TValue Initializes a new instance of the CachedObjectManagerByMaximumNumberOfItemsTKey, TValue class.
Top
Methods
 NameDescription
Public methodAdd Adds an object under the specified key.
Public methodClear Removes all items in the collection. If the values implement IDisposable, the items are disposed.
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Public methodTryTake 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