public void Deque_Clear(int count)
 {
     var elements = new TestDequeElement[count];
     for (var i = 0; i < count; i++)
     {
         elements[i] = new TestDequeElement
         {
             Value = i
         };
     }
     var deque = new Deque<TestDequeElement>(elements);
     deque.Clear();
     Assert.IsTrue(deque.Count == 0);
     Assert.IsTrue(deque.Capacity >= count);
 }
Beispiel #2
0
        public void Deque_Clear(int count)
        {
            var elements = new TestDequeElement[count];

            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque = new Deque <TestDequeElement>(elements);

            deque.Clear();
            Assert.True(deque.Count == 0);
            Assert.True(deque.Capacity >= count);
        }
 public void Deque_Constructor_Collection(int count)
 {
     var elements = new TestDequeElement[count];
     for (var i = 0; i < count; i++)
     {
         elements[i] = new TestDequeElement
         {
             Value =  i
         };
     }
     var deque = new Deque<TestDequeElement>(elements);
     Assert.IsTrue(deque.Count == count);
     Assert.IsTrue(deque.Capacity == count);
     for (var index = 0; index < deque.Count; index++)
     {
         Assert.IsTrue(deque[index].Value == index); 
     }
 }
Beispiel #4
0
        public void Deque_Constructor_Collection(int count)
        {
            var elements = new TestDequeElement[count];

            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque = new Deque <TestDequeElement>(elements);

            Assert.True(deque.Count == count);
            Assert.True(deque.Capacity == count);
            for (var index = 0; index < deque.Count; index++)
            {
                Assert.True(deque[index].Value == index);
            }
        }
Beispiel #5
0
        public void Deque_ForEach_Iteration(int count)
        {
            var elements = new TestDequeElement[count];

            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque   = new Deque <TestDequeElement>(elements);
            var counter = 0;

            foreach (var element in deque)
            {
                Assert.True(element.Value == counter);
                counter++;
            }
        }
Beispiel #6
0
        public void Deque_Get_Index(int count)
        {
            var elements = new TestDequeElement[count];

            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque   = new Deque <TestDequeElement>(elements);
            var indices = Enumerable.Range(0, count).ToList().Shuffle(_random);

            foreach (var index in indices)
            {
                deque.Get(index, out var element);
                Assert.True(element.Value == index);
            }
        }
Beispiel #7
0
        public void Deque_Get_Back(int count)
        {
            var elements = new TestDequeElement[count];

            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque   = new Deque <TestDequeElement>(elements);
            var indices = Enumerable.Range(0, count);

            foreach (var index in indices)
            {
                deque.GetBack(out var element);
                deque.RemoveFromBack();
                Assert.True(element.Value == count - 1 - index);
            }
        }
Beispiel #8
0
        public void Deque_Remove_Back(int count)
        {
            var elements = new TestDequeElement[count];

            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque = new Deque <TestDequeElement>(elements);

            var index = 0;

            while (deque.RemoveFromBack(out var element))
            {
                Assert.True(element.Value == elements.Length - 1 - index);
                index++;
            }
        }
Beispiel #9
0
        public void Deque_Trim_Back(int count)
        {
            var elements = new TestDequeElement[count];

            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque = new Deque <TestDequeElement>(elements);

            for (var i = 0; i < count; i++)
            {
                deque.RemoveFromBack(out _);
                deque.Capacity = deque.Count;
                Assert.True(deque.Count == count - 1 - i);
                Assert.True(deque.Capacity == count - 1 - i);
            }
        }
        public void Deque_Remove_Front(int count)
        {
            var elements = new TestDequeElement[count];

            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque = new Deque <TestDequeElement>(elements);

            TestDequeElement element;
            var index = 0;

            while (deque.RemoveFromFront(out element))
            {
                Assert.IsTrue(element.Value == index);
                index++;
            }
        }
        public void Deque_Get_Front(int count)
        {
            var elements = new TestDequeElement[count];

            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque   = new Deque <TestDequeElement>(elements);
            var indices = Enumerable.Range(0, count);

            foreach (var index in indices)
            {
                TestDequeElement element;
                deque.GetFront(out element);
                deque.RemoveFromFront();
                Assert.IsTrue(element.Value == index);
            }
        }
Beispiel #12
0
        public void Deque_Remove(int count)
        {
            var elements = new TestDequeElement[count];

            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque   = new Deque <TestDequeElement>(elements);
            var counter = count;

            while (deque.Count > 0)
            {
                var index = _random.Next(0, deque.Count - 1);
                deque.RemoveAt(index);
                counter--;
                Assert.True(deque.Count == counter);
            }
        }
 public void Deque_Remove(int count)
 {
     var elements = new TestDequeElement[count];
     for (var i = 0; i < count; i++)
     {
         elements[i] = new TestDequeElement
         {
             Value = i
         };
     }
     var deque = new Deque<TestDequeElement>(elements);
     var counter = count;
     while (deque.Count > 0)
     {
         var index = _random.Next(0, deque.Count - 1);
         deque.RemoveAt(index);
         counter--;
         Assert.IsTrue(deque.Count == counter);
     }
 }
 public void Deque_ForEach_Iteration_Modified(int count)
 {
     var elements = new TestDequeElement[count];
     for (var i = 0; i < count; i++)
     {
         elements[i] = new TestDequeElement
         {
             Value = i
         };
     }
     var deque = new Deque<TestDequeElement>(elements);
     var counter = 0;
     foreach (var element in deque)
     {
         Assert.IsTrue(element.Value == counter);
         counter++;
         deque.RemoveFromFront();
     }
 }
 public void Deque_Get_Index(int count)
 {
     var elements = new TestDequeElement[count];
     for (var i = 0; i < count; i++)
     {
         elements[i] = new TestDequeElement
         {
             Value = i
         };
     }
     var deque = new Deque<TestDequeElement>(elements);
     var indices = Enumerable.Range(0, count).ToList().Shuffle(_random);
     foreach (var index in indices)
     {
         TestDequeElement element;
         deque.Get(index, out element);
         Assert.IsTrue(element.Value == index);
     }
 }
 public void Deque_Get_Back(int count)
 {
     var elements = new TestDequeElement[count];
     for (var i = 0; i < count; i++)
     {
         elements[i] = new TestDequeElement
         {
             Value = i
         };
     }
     var deque = new Deque<TestDequeElement>(elements);
     var indices = Enumerable.Range(0, count);
     foreach (var index in indices)
     {
         TestDequeElement element;
         deque.GetBack(out element);
         deque.RemoveFromBack();
         Assert.IsTrue(element.Value == count - 1 - index);
     }
 }
        public void Deque_Remove_Back(int count)
        {
            var elements = new TestDequeElement[count];
            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque = new Deque<TestDequeElement>(elements);

            TestDequeElement element;
            var index = 0;
            while (deque.RemoveFromBack(out element))
            {
                Assert.IsTrue(element.Value == elements.Length - 1 - index);
                index++;
            }
        }
        public void Deque_Trim_Back(int count)
        {
            var elements = new TestDequeElement[count];
            for (var i = 0; i < count; i++)
            {
                elements[i] = new TestDequeElement
                {
                    Value = i
                };
            }
            var deque = new Deque<TestDequeElement>(elements);

            for (var i = 0; i < count; i++)
            {
                TestDequeElement element;
                deque.RemoveFromBack(out element);
                deque.Capacity = deque.Count;
                Assert.IsTrue(deque.Count == count - 1 - i);
                Assert.IsTrue(deque.Capacity == count - 1 - i);
            }
        }