public static Dictionary <TKey, TValue> AllocateAndClear <TKey, TValue>( this SimplePool <Dictionary <TKey, TValue> > pool) { var map = pool.Allocate(); map.Clear(); return(map); }
private static int[,] GetMatrix(int width, int height) { if (width > MaxMatrixPoolDimension || height > MaxMatrixPoolDimension) { return(InitializeMatrix(new int[width, height])); } return(s_matrixPool.Allocate()); }
public static T[] GetArray(int size) { if (size <= MaxPooledArraySize) { var array = s_pool.Allocate(); Array.Clear(array, 0, array.Length); return(array); } return(new T[size]); }