Beispiel #1
0
        /// <summary>
        /// Gets an array from the pool, constructing a new array if necessary.
        /// Dispose of the array to put is back into the pool for reuse.
        /// </summary>
        /// <returns></returns>
        public ReusableArray <T> GetArray()
        {
            var array = _pool.PopLast();

            if (ReferenceEquals(array, null))
            {
                array = new ReusableArray <T>(_length, a => _pool.Append(a));
            }

            return(array);
        }
 public Enumerator(ReusableArray <T> array)
 {
     _array = array;
     _index = -1;
 }