Class DictionaryPool<TKey, TValue>
Object pool for System.Collections.Generic.Dictionary<, > instances.
Inheritance
Implements
Inherited Members
Namespace: System.Collections.Generic
Assembly: Nuqleon.Memory.dll
Syntax
public abstract class DictionaryPool<TKey, TValue> : ObjectPoolBase<PooledDictionary<TKey, TValue>>, IObjectPool<PooledDictionary<TKey, TValue>>, IObjectPoolAllocateFree<PooledDictionary<TKey, TValue>>, IObjectPoolNew<PooledDictionary<TKey, TValue>>
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the keys in the dictionary. |
| TValue | The type of the values in the dictionary. |
Constructors
DictionaryPool(Int32)
Creates a new System.Collections.Generic.Dictionary<, > pool of the specified pool size.
Declaration
protected DictionaryPool(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.Collections.Generic.Dictionary<, > instances to keep in the pool. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
Methods
Create(Int32)
Creates a new System.Collections.Generic.Dictionary<, > pool of the specified pool size. The pool creates new instances of System.Collections.Generic.Dictionary<, > by calling the default constructor on Dictionary{TKey, TValue}.
Declaration
public static DictionaryPool<TKey, TValue> Create(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.Collections.Generic.Dictionary<, > instances to keep in the pool. |
Returns
| Type | Description |
|---|---|
| DictionaryPool<TKey, TValue> | Newly created pool for System.Collections.Generic.Dictionary<, > instances. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
Create(Int32, IEqualityComparer<TKey>)
Creates a new System.Collections.Generic.Dictionary<, > pool of the specified pool size.
The pool creates new instances of System.Collections.Generic.Dictionary<, > by calling the constructor on System.Collections.Generic.Dictionary<, >, passing in the specified comparer.
Declaration
public static DictionaryPool<TKey, TValue> Create(int size, IEqualityComparer<TKey> comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.Collections.Generic.Dictionary<, > instances to keep in the pool. |
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | The System.Collections.Generic.IEqualityComparer<> implementation to use when comparing keys, or null to use the default System.Collections.Generic.EqualityComparer`1 for the type of the key. |
Returns
| Type | Description |
|---|---|
| DictionaryPool<TKey, TValue> | Newly created pool for System.Collections.Generic.Dictionary<, > instances. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
Create(Int32, Int32)
Creates a new System.Collections.Generic.Dictionary<, > pool of the specified pool size.
The pool creates new instances of System.Collections.Generic.Dictionary<, > by calling the constructor on System.Collections.Generic.Dictionary<, >, passing in the specified capacity.
Declaration
public static DictionaryPool<TKey, TValue> Create(int size, int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.Collections.Generic.Dictionary<, > instances to keep in the pool. |
| System.Int32 | capacity | The initial number of elements that the System.Collections.Generic.Dictionary<, > can contain. |
Returns
| Type | Description |
|---|---|
| DictionaryPool<TKey, TValue> | Newly created pool for System.Collections.Generic.Dictionary<, > instances. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
Create(Int32, Int32, IEqualityComparer<TKey>)
Creates a new System.Collections.Generic.Dictionary<, > pool of the specified pool size.
The pool creates new instances of System.Collections.Generic.Dictionary<, > by calling the constructor on System.Collections.Generic.Dictionary<, >, passing in the specified capacity and comparer.
Declaration
public static DictionaryPool<TKey, TValue> Create(int size, int capacity, IEqualityComparer<TKey> comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.Collections.Generic.Dictionary<, > instances to keep in the pool. |
| System.Int32 | capacity | The initial number of elements that the System.Collections.Generic.Dictionary<, > can contain. |
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | The System.Collections.Generic.IEqualityComparer<> implementation to use when comparing keys, or null to use the default System.Collections.Generic.EqualityComparer`1 for the type of the key. |
Returns
| Type | Description |
|---|---|
| DictionaryPool<TKey, TValue> | Newly created pool for System.Collections.Generic.Dictionary<, > instances. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
Create(Int32, Int32, IEqualityComparer<TKey>, Int32)
Creates a new System.Collections.Generic.Dictionary<, > pool of the specified pool size.
The pool creates new instances of System.Collections.Generic.Dictionary<, > by calling the constructor on System.Collections.Generic.Dictionary<, >, passing in the specified capacity and comparer.
Declaration
public static DictionaryPool<TKey, TValue> Create(int size, int capacity, IEqualityComparer<TKey> comparer, int maxCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.Collections.Generic.Dictionary<, > instances to keep in the pool. |
| System.Int32 | capacity | The initial number of elements that the System.Collections.Generic.Dictionary<, > can contain. |
| System.Collections.Generic.IEqualityComparer<TKey> | comparer | The System.Collections.Generic.IEqualityComparer<> implementation to use when comparing keys, or null to use the default System.Collections.Generic.EqualityComparer`1 for the type of the key. |
| System.Int32 | maxCapacity | The maximum capacity allowed for pooled instances. |
Returns
| Type | Description |
|---|---|
| DictionaryPool<TKey, TValue> | Newly created pool for System.Collections.Generic.Dictionary<, > instances. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
New()
Gets a holder to a pooled dictionary instance with RAII capabilities to return it to the pool.
Declaration
public PooledDictionaryHolder<TKey, TValue> New()
Returns
| Type | Description |
|---|---|
| PooledDictionaryHolder<TKey, TValue> | Holder to a pooled dictionary instance. |