A* Pathfinding Project
4.0.0
The A* Pathfinding Project for Unity 3D
|
Lightweight Array Pool. More...
Lightweight Array Pool.
Handy class for pooling arrays of type T.
Usage:
After you have released a array, you should never use it again, if you do use it your code may modify it at the same time as some other code is using it which will likely lead to bad results.
Static Public Member Functions | |
static T[] | Claim (int minimumLength) |
Returns an array with at least the specified length. | |
static T[] | ClaimWithExactLength (int length) |
Returns an array with the specified length. | |
static void | Release (ref T[] array) |
Static Private Attributes | |
static readonly Dictionary < int, Stack< T[]> > | exactPool = new Dictionary<int, Stack<T[]> >() |
static readonly HashSet< T[]> | inPool = new HashSet<T[]>() |
static readonly Stack< T[]>[] | pool = new Stack<T[]>[31] |
Internal pool. | |
|
static |
Returns an array with at least the specified length.
|
static |
Returns an array with the specified length.
Use with caution as pooling too many arrays with different lengths that are rarely being reused will lead to an effective memory leak.
Use Claim if you just need an array that is at least as large as some value.
|
static |
|
staticprivate |
|
staticprivate |
|
staticprivate |
Internal pool.
The arrays in each bucket have lengths of 2^i