|
A* Pathfinding Project
3.8.2
The A* Pathfinding Project for Unity 3D
|
Lightweight List Pool. More...
Lightweight List Pool.
Handy class for pooling lists of type T.
Usage:
You do not need to clear the list before releasing it. After you have released a list, you should never use it again, if you do use it, you will mess things up quite badly in the worst case.
Static Public Member Functions | |
| static List< T > | Claim () |
| Claim a list. | |
| static List< T > | Claim (int capacity) |
| Claim a list with minimum capacity Returns a pooled list if any are in the pool. | |
| static void | Clear () |
| Clears the pool for lists of this type. | |
| static int | GetSize () |
| Number of lists of this type in the pool. | |
| static void | Release (List< T > list) |
| Releases a list. | |
| static void | Warmup (int count, int size) |
| Makes sure the pool contains at least count pooled items with capacity size. | |
Private Attributes | |
| const int | MaxCapacitySearchLength = 8 |
| When requesting a list with a specified capacity, search max this many lists in the pool before giving up. | |
Static Private Attributes | |
| static readonly HashSet< List < T > > | inPool = new HashSet<List<T> >() |
| static readonly List< List< T > > | pool = new List<List<T> >() |
| Internal pool. | |
|
static |
Claim a list.
Returns a pooled list if any are in the pool. Otherwise it creates a new one. After usage, this list should be released using the Release function (though not strictly necessary).
|
static |
Claim a list with minimum capacity Returns a pooled list if any are in the pool.
Otherwise it creates a new one. After usage, this list should be released using the Release function (though not strictly necessary). This list returned will have at least the capacity specified.
|
static |
Clears the pool for lists of this type.
This is an O(n) operation, where n is the number of pooled lists.
|
static |
Number of lists of this type in the pool.
|
static |
Releases a list.
After the list has been released it should not be used anymore.
| System.InvalidOperationException | Releasing a list when it has already been released will cause an exception to be thrown. |
|
static |
Makes sure the pool contains at least count pooled items with capacity size.
This is good if you want to do all allocations at start.
|
staticprivate |
|
private |
When requesting a list with a specified capacity, search max this many lists in the pool before giving up.
Must be greater or equal to one.
|
staticprivate |
Internal pool.