A* Pathfinding Project
4.3.2
The A* Pathfinding Project for Unity 3D
|
Lightweight Stack Pool. More...
Lightweight Stack Pool.
Handy class for pooling stacks of type T.
Usage:
You do not need to clear the stack before releasing it. After you have released a stack, you should never use it again.
Static Public Member Functions | |
static Stack< T > | Claim () |
Claim a stack. More... | |
static void | Clear () |
Clears all pooled stacks of this type. More... | |
static int | GetSize () |
Number of stacks of this type in the pool. More... | |
static void | Release (Stack< T > stack) |
Releases a stack. More... | |
static void | Warmup (int count) |
Makes sure the pool contains at least count pooled items. More... | |
Static Private Member Functions | |
static | StackPool () |
Static constructor. More... | |
Static Private Attributes | |
static readonly List< Stack< T > > | pool |
Internal pool. More... | |
|
staticprivate |
Static constructor.
|
static |
Claim a stack.
Returns a pooled stack if any are in the pool. Otherwise it creates a new one. After usage, this stack should be released using the Release function (though not strictly necessary).
|
static |
Clears all pooled stacks of this type.
This is an O(n) operation, where n is the number of pooled stacks
|
static |
Number of stacks of this type in the pool.
|
static |
Releases a stack.
After the stack has been released it should not be used anymore. Releasing a stack twice will cause an error.
|
static |
Makes sure the pool contains at least count pooled items.
This is good if you want to do all allocations at start.
|
staticprivate |
Internal pool.