예제 #1
0
        /// <summary>
        /// Shrinks the available ids queue to the smallest size that can fit the given count and the current available id count.
        /// </summary>
        /// <param name="queuedCount">Number of elements to guarantee space for in the available ids queue.</param>
        public void Compact <TPool>(int queuedCount, TPool pool) where TPool : IMemoryPool <int, TSpan>
        {
            var targetLength = BufferPool <int> .GetLowestContainingElementCount(Math.Max(queuedCount, AvailableIds.Count));

            if (AvailableIds.Span.Length > targetLength)
            {
                AvailableIds.Resize(targetLength, pool);
            }
        }