예제 #1
0
        public static Dictionary <TKey, TValue> AllocateAndClear <TKey, TValue>(
            this SimplePool <Dictionary <TKey, TValue> > pool)
        {
            var map = pool.Allocate();

            map.Clear();

            return(map);
        }
예제 #2
0
        private static int[,] GetMatrix(int width, int height)
        {
            if (width > MaxMatrixPoolDimension || height > MaxMatrixPoolDimension)
            {
                return(InitializeMatrix(new int[width, height]));
            }

            return(s_matrixPool.Allocate());
        }
예제 #3
0
        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]);
        }