Click or drag to resize

PersistentDictionaryTKey, TValue Class

A dictionary that maps keys to values and is persistent. Persistence means that an instance of this type, once created, cannot be changed. Methods like Add(TKey, TValue) return a new instance instead of modifying the one on which they are called. The new instance shares much of its structure with the original, so modifications are still efficient. This class is useful in multithreaded applications. An instance of this type cannot be created directly. The Empty field contains an empty instance with which to start.
Inheritance Hierarchy
SystemObject
  AGI.Foundation.Infrastructure.ThreadingPersistentDictionaryNodeTKey, TValue
    AGI.Foundation.Infrastructure.ThreadingPersistentDictionaryTKey, TValue

Namespace:  AGI.Foundation.Infrastructure.Threading
Assembly:  AGI.Foundation.Core (in AGI.Foundation.Core.dll) Version: 24.1.418.0 (24.1.418.0)
Syntax
public abstract class PersistentDictionary<TKey, TValue> : PersistentDictionaryNode<TKey, TValue>, 
	IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable

Type Parameters

TKey
The type of the key in the dictionary.
TValue
The type of the value in the dictionary.

The PersistentDictionaryTKey, TValue type exposes the following members.

Constructors
  NameDescription
Protected methodPersistentDictionaryTKey, TValue
Initializes a new instance of the PersistentDictionaryTKey, TValue class
Top
Properties
  NameDescription
Public propertyCount
Gets the number of elements in this dictionary.
Public propertyItem
Gets the value corresponding to the specified key. Throws KeyNotFoundException if the key does not exist in the dictionary.
Public propertyKeys
Gets a read-only collection of keys in the dictionary.
Public propertyValues
Gets a read-only collection of values in the dictionary.
Top
Methods
  NameDescription
Public methodAdd(TKey, TValue)
Adds a specified key/value pair to the dictionary. If a value with the specified key already exists, it is replaced. This method does not modify the dictionary on which it is called but instead returns a new dictionary containing the added element.
Public methodAdd(TKey, TValue, PersistentDictionaryAddResult)
Adds a specified key/value pair to the dictionary, and returns a value indicating whether the key was newly added to the dictionary or it already existed and the value was replaced. This method does not modify the dictionary on which it is called but instead returns a new dictionary containing the added element.
Public methodContainsKey
Determines if a specified key exists in the dictionary.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetEnumerator
Gets an enumerator for enumerating over the key/value pairs in the dictionary.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRemove
Removes an item with the specified key from the dictionary. This method does not modify the instance on which it is called but instead returns a new instance with the element removed. If the key does not exist in the dictionary, this method returns the instance on which it is called.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTryGetValue
Gets the value in the dictionary corresponding to the given key.
Top
Fields
  NameDescription
Public fieldStatic memberEmpty
An empty dictionary.
Top
See Also