Class PooledDictionary<TKey, TValue>
Represents a collection of keys and values. Instances of this type are kept in a pool for recycling.
Inheritance
Namespace: System.Collections.Generic
Assembly: Nuqleon.Memory.dll
Syntax
public class PooledDictionary<TKey, TValue> : Dictionary<TKey, TValue>, IFreeable, IClearable
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys in the dictionary. |
TValue | The type of the values in the dictionary. |
Constructors
PooledDictionary(SerializationInfo, StreamingContext)
Initializes a new instance of the PooledDictionary<TKey, TValue> class with serialized data.
Declaration
protected PooledDictionary(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | A System.Runtime.Serialization.SerializationInfo object containing the information required to serialize the PooledDictionary<TKey, TValue>. |
System.Runtime.Serialization.StreamingContext | context | A System.Runtime.Serialization.StreamingContext structure containing the source and destination of the serialized stream associated with the PooledDictionary<TKey, TValue>. |
Methods
Free()
Frees the object and returns it to the pool.
Declaration
public void Free()
GetInstance()
Gets a System.Collections.Generic.Dictionary<, > instance from the global dictionary pool.
Declaration
public static PooledDictionary<TKey, TValue> GetInstance()
Returns
Type | Description |
---|---|
PooledDictionary<TKey, TValue> | A System.Collections.Generic.Dictionary<, > instance obtained from the global pool. |
New()
Gets a pooled System.Collections.Generic.Dictionary<, > instance, from the global pool, with RAII capabilities to return it to the pool.
Declaration
public static PooledDictionaryHolder<TKey, TValue> New()
Returns
Type | Description |
---|---|
PooledDictionaryHolder<TKey, TValue> | Pooled dictionary instance. |
New(DictionaryPool<TKey, TValue>)
Gets a pooled System.Collections.Generic.Dictionary<, > instance, from the specified pool, with RAII capabilities to return it to the pool.
Declaration
public static PooledDictionaryHolder<TKey, TValue> New(DictionaryPool<TKey, TValue> pool)
Parameters
Type | Name | Description |
---|---|---|
DictionaryPool<TKey, TValue> | pool | Pool to allocate from. |
Returns
Type | Description |
---|---|
PooledDictionaryHolder<TKey, TValue> | Pooled dictionary instance. |
Exceptions
Type | Condition |
---|---|
System.NullReferenceException | Thrown if |