Exemplo n.º 1
0
        public static void ClearTest()
        {
            var array = new UnmanagedArray <int>(3);

            array[0] = 1;
            array[1] = 2;
            array[2] = 3;

            using (var valueQueue = new UnmanagedValueQueue <int>(array, takeOwnership: false))
            {
                valueQueue.Clear();

                Assert.That(() => valueQueue,
                            Has.Property("Capacity").EqualTo((nuint)3)
                            .And.Count.EqualTo((nuint)0)
                            );
            }

            using (var valueQueue = new UnmanagedValueQueue <int>(array, takeOwnership: false))
            {
                _ = valueQueue.Dequeue();

                valueQueue.Enqueue(4);
                valueQueue.Clear();

                Assert.That(() => valueQueue,
                            Has.Property("Capacity").EqualTo((nuint)3)
                            .And.Count.EqualTo((nuint)0)
                            );
            }

            using (var valueQueue = new UnmanagedValueQueue <int>(array, takeOwnership: true))
            {
                _ = valueQueue.Dequeue();

                valueQueue.Enqueue(4);
                valueQueue.Enqueue(5);

                valueQueue.Clear();

                Assert.That(() => valueQueue,
                            Has.Property("Capacity").EqualTo((nuint)6)
                            .And.Count.EqualTo((nuint)0)
                            );
            }

            using (var valueQueue = new UnmanagedValueQueue <int>())
            {
                valueQueue.Clear();

                Assert.That(() => valueQueue,
                            Has.Property("Capacity").EqualTo((nuint)0)
                            .And.Count.EqualTo((nuint)0)
                            );
            }
        }
Exemplo n.º 2
0
 /// <summary>Removes all items from the pool.</summary>
 public void Clear()
 {
     _items.Clear();
     _availableItems.Clear();
 }