Interface IListPool<T>
A basic interface for classes which act as a pool of List<T> structures. It provides functions to rent lists from the pool, return them, and limit the number of lists kept in the pool.
Namespace: SadRogue.Primitives.Pooling
Assembly: TheSadRogue.Primitives.dll
Syntax
public interface IListPool<T>
Type Parameters
| Name | Description |
|---|---|
| T | Type of items being stored in the list. |
Remarks
The API for this interface is generally inspired by ArrayPool<T>, and serves a similar purpose, except for lists. Note that, at the current time, the API is more limited and the implementation less efficient than ArrayPool. The biggest difference is that this pool effectively assumes lists are blank, and doesn't have any way to take into account list capacity when requesting a list.
Methods
Clear()
Clears the pool of all lists.
Declaration
void Clear()
Rent()
Retrieve a list from the pool, or allocate a new one if there are no lists available.
Declaration
List<T> Rent()
Returns
| Type | Description |
|---|---|
| List<T> | A list from the pool, or a new list if no lists are available in the pool. |
Return(List<T>, Boolean)
Returns the given list to the pool.
Declaration
void Return(List<T> list, bool clear = true)
Parameters
| Type | Name | Description |
|---|---|---|
| List<T> | list | The list to return. |
| Boolean | clear | Whether or not to clear the list given before adding it to the pool. Should be set to true unless you are absolutely sure the list is cleared via other means before passing it. |