A* Pathfinding Project  3.8.9
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
ArrayPool< T > Class Template Reference

Lightweight Array Pool. More...

Detailed Description

Lightweight Array Pool.

Handy class for pooling arrays of type T.

Usage:

  • Claim a new array using
    SomeClass[] foo = ArrayPool<SomeClass>.Claim (capacity);
  • Use it and do stuff with it
  • Release it with
    ArrayPool<SomeClass>.Release (foo);
Warning
Arrays returned from the Claim method may contain arbitrary data. You cannot rely on it being zeroed out.

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.

Since
Version 3.8.6
See Also
Pathfinding.Util.ListPool

Static Public Member Functions

static T[] Claim (int minimumLength)
 Returns an array with at least the specified length.
 
static void Release (ref T[] array)
 

Static Private Attributes

static readonly HashSet< T[]> inPool = new HashSet<T[]>()
 
static readonly Stack< T[]>[] pool = new Stack<T[]>[31]
 Internal pool.
 

Member Function Documentation

static T [] Claim ( int  minimumLength)
static

Returns an array with at least the specified length.

static void Release ( ref T[]  array)
static

Member Data Documentation

readonly HashSet<T[]> inPool = new HashSet<T[]>()
staticprivate
readonly Stack<T[]> [] pool = new Stack<T[]>[31]
staticprivate

Internal pool.

The arrays in each bucket have lengths of 2^i


The documentation for this class was generated from the following file: