示例#1
0
        /// <summary>
        /// testing out new Queue
        /// </summary>
        static void QueueWithStacks()
        {
            Queue TestQueue = new Queue();

            TestQueue.Enqueue(new Node("Papa"));
            Console.WriteLine($"Made a Queue and its first value is {TestQueue.Peek().Data}");
            TestQueue.Enqueue(new Node("Can"));
            TestQueue.Enqueue(new Node("You"));
            TestQueue.Enqueue(new Node("Hear"));
            TestQueue.Enqueue(new Node("Me?"));
            Console.WriteLine($"Adding some more nodes with string \" Can You Hear Me \" and its first value should still be {TestQueue.Peek().Data}");
            TestQueue.Dequeue();
            Console.WriteLine($"Removing the front node and its value should be {TestQueue.Peek().Data}");
            TestQueue.Dequeue();
            Console.WriteLine($"Removing the front node and its value should be {TestQueue.Peek().Data}");
            TestQueue.Dequeue();
            Console.WriteLine($"Removing the front node and its value should be {TestQueue.Peek().Data}");
            TestQueue.Dequeue();
            Console.WriteLine($"Removing the front node and its value should be {TestQueue.Peek().Data}");
            TestQueue.Enqueue(new Node("Can"));
            TestQueue.Enqueue(new Node("You"));
            TestQueue.Enqueue(new Node("Hear"));
            TestQueue.Enqueue(new Node("Me?"));
            Console.WriteLine($"Adding some more nodes with string \" Can You Hear Me \" and its first value should still be {TestQueue.Peek().Data}");
            TestQueue.Dequeue();
            Console.WriteLine($"Removing the front node and its value should be {TestQueue.Peek().Data}");
        }
        public void FIFOTestEnqueue()
        {
            Node  One       = new Node("Papa");
            Node  Two       = new Node("Mama");
            Queue TestQueue = new Queue();

            TestQueue.Enqueue(One);
            TestQueue.Enqueue(Two);
            Assert.Equal(One, TestQueue.Peek());
        }
        public void SizeTest()
        {
            Node  One       = new Node("Papa");
            Node  Two       = new Node("Mama");
            Queue TestQueue = new Queue();

            TestQueue.Enqueue(One);
            TestQueue.Enqueue(null);
            TestQueue.Enqueue(Two);
            Assert.Equal(2, TestQueue.GetSize());
        }