System.Collections.Tests.QueueTests.TrimToSize_Wrapped C# (CSharp) Метод

TrimToSize_Wrapped() приватный Метод

private TrimToSize_Wrapped ( ) : void
Результат void
        public static void TrimToSize_Wrapped()
        {
            var queue = new Queue(100);

            // Insert 50 items in the Queue
            for (int i = 0; i < 50; i++)
            {
                queue.Enqueue(i);
            }

            // Insert and Remove 75 items in the Queue. This should wrap the queue 
            // where there is 25 at the end of the array and 25 at the beginning
            for (int i = 0; i < 75; i++)
            {
                queue.Enqueue(i + 50);
                queue.Dequeue();
            }

            queue.TrimToSize();
            Assert.Equal(50, queue.Count);
            Assert.Equal(75, queue.Dequeue());

            queue.Enqueue(100);
            Assert.Equal(50, queue.Count);
            Assert.Equal(76, queue.Dequeue());
        }