Class ListPool<T>
Object pool for System.Collections.Generic.List<> instances.
Implements
Inherited Members
Namespace: System.Collections.Generic
Assembly: Nuqleon.Memory.dll
Syntax
public abstract class ListPool<T> : ObjectPoolBase<PooledList<T>>, IObjectPool<PooledList<T>>, IObjectPoolAllocateFree<PooledList<T>>, IObjectPoolNew<PooledList<T>>
Type Parameters
| Name | Description |
|---|---|
| T | The type of elements in the list. |
Constructors
ListPool(Int32)
Creates a new System.Collections.Generic.List<> pool of the specified pool size.
Declaration
protected ListPool(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.Collections.Generic.List<> instances to keep in the pool. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
Methods
Create(Int32)
Creates a new System.Collections.Generic.List<> pool of the specified pool size. The pool creates new instances of System.Collections.Generic.List<> by calling the default constructor on List{T}.
Declaration
public static ListPool<T> Create(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.Collections.Generic.List<> instances to keep in the pool. |
Returns
| Type | Description |
|---|---|
| ListPool<T> | Newly created pool for System.Collections.Generic.List<> instances. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
Create(Int32, Int32)
Creates a new System.Collections.Generic.List<> pool of the specified pool size.
The pool creates new instances of System.Collections.Generic.List<> by calling the constructor on System.Collections.Generic.List<>, passing in the specified capacity.
Declaration
public static ListPool<T> Create(int size, int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.Collections.Generic.List<> instances to keep in the pool. |
| System.Int32 | capacity | The number of elements that the new list can initially store. |
Returns
| Type | Description |
|---|---|
| ListPool<T> | Newly created pool for System.Collections.Generic.List<> instances. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
Create(Int32, Int32, Int32)
Creates a new System.Collections.Generic.List<> pool of the specified pool size.
The pool creates new instances of System.Collections.Generic.List<> by calling the constructor on System.Collections.Generic.List<>, passing in the specified capacity.
Declaration
public static ListPool<T> Create(int size, int capacity, int maxCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.Collections.Generic.List<> instances to keep in the pool. |
| System.Int32 | capacity | The number of elements that the new list can initially store. |
| System.Int32 | maxCapacity | The maximum capacity allowed for pooled instances. |
Returns
| Type | Description |
|---|---|
| ListPool<T> | Newly created pool for System.Collections.Generic.List<> instances. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
New()
Gets a holder to a pooled list instance with RAII capabilities to return it to the pool.
Declaration
public PooledListHolder<T> New()
Returns
| Type | Description |
|---|---|
| PooledListHolder<T> | Holder to a pooled list instance. |