Exemplo n.º 1
0
        static void Main(string[] args)
        {
            DynamicQueue<int> queue = new DynamicQueue<int>();
            queue.Enqueue(5);
            queue.Enqueue(31);
            queue.Enqueue(100);

            Console.WriteLine(queue.Contains(101));

            Console.WriteLine(queue.Peek());
            Console.WriteLine(queue.Peek());
            Console.WriteLine(queue.Dequeue());
            Console.WriteLine(queue.Dequeue());
            Console.WriteLine(queue.Peek());
            queue.Enqueue(666);
            Console.WriteLine(queue.Dequeue());
        }
Exemplo n.º 2
0
        public void Dequeue_ReturnsItems()
        {
            var queue = new DynamicQueue<int>();

            queue.Enqueue(10);
            queue.Enqueue(100);
            queue.Enqueue(200);

            //should be three items in the queue
            Assert.IsTrue(queue.CurrentSize == 3);

            var item = queue.Dequeue();

            //dequeued item should be 10
            Assert.IsTrue(item ==  10);

            //items in the queue should be 2
            Assert.IsTrue(queue.CurrentSize == 2);

            item = queue.Dequeue();

            //dequeued item should be 100
            Assert.IsTrue(item == 100);

            //items in the queue should be 1
            Assert.IsTrue(queue.CurrentSize == 1);

            item = queue.Dequeue();

            //dequeued item should be 200
            Assert.IsTrue(item == 200);

            //items in the queue should be 0 and queue is empty
            Assert.IsTrue(queue.CurrentSize ==0);
            Assert.IsTrue(queue.IsEmpty() == true);


        }
Exemplo n.º 3
0
        public void Dequeue_EmptyQueue_ReturnsDefaultForItems()
        {
            var intQueue = new DynamicQueue<int>();
            var intItem = intQueue.Dequeue();

            Assert.IsTrue(intQueue.CurrentSize == 0);
            Assert.IsTrue(intItem  == default(int));

            var stringQueue = new DynamicQueue<string>();
            var stringItem = stringQueue.Dequeue();

            Assert.IsTrue(stringQueue.CurrentSize == 0);
            Assert.IsTrue(stringItem == default(string));
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            DynamicQueue<int> queue = new DynamicQueue<int>();

            Console.WriteLine("Enqueue first number: 5");
            queue.Enqueue(5);
            Console.WriteLine("Enqueue first number: 6");
            queue.Enqueue(6);
            Console.WriteLine("Enqueue first number: 7");
            queue.Enqueue(7);
            Console.WriteLine("Enqueue first number: 8");
            queue.Enqueue(8);
            Console.WriteLine("Current count is: {0}", queue.Count());
            Console.WriteLine("Check first enqueued element: {0}", queue.Peek());
            Console.WriteLine("Dequeue element");
            var element = queue.Dequeue();
            Console.WriteLine("The dequeued element is: {0}", element);
            Console.WriteLine("Queue count after dequeuing an element: {0}", queue.Count());
        }
        public void TestDequeue_NonEmptyQueue()
        {
            DynamicQueue <int> queue = new DynamicQueue <int>();

            int[] arr = new int[5];

            for (int i = 1; i <= 5; i++)
            {
                queue.Enqueue(i);
                arr[i - 1] = i;
            }

            int value = 0;

            for (int i = 0; i < 5; i++)
            {
                value = queue.Dequeue();
                Assert.AreEqual(arr[i], value);
            }

            Assert.AreEqual(0, queue.Count);
        }
 public void TestDequeue_EmptyQueue()
 {
     DynamicQueue <int> queue = new DynamicQueue <int>();
     int value = queue.Dequeue();
 }