Exemplo n.º 1
0
        public void TestMultipleeEnqueues()
        {
            Stack stackOne = new Stack(null);
            Stack stackTwo = new Stack(null);

            Node node1 = new Node(1);
            Node node2 = new Node(2);
            Node node3 = new Node(3);
            Node node4 = new Node(4);
            Node node5 = new Node(5);

            QueueOfStacks queue = new QueueOfStacks(stackOne, stackTwo);

            queue.Enqueue(node1);
            queue.Enqueue(node2);
            queue.Enqueue(node3);

            queue.Dequeue();
            queue.Dequeue();

            queue.Enqueue(node4);
            queue.Enqueue(node5);

            Assert.Equal(3, queue.Dequeue().Value);
        }
Exemplo n.º 2
0
        public void TestQueueOfStacks()
        {
            QueueOfStacks q = new QueueOfStacks();

            q.Enqueue(1);
            q.Enqueue(2);
            q.Enqueue(3);
            q.Enqueue(4);
            q.Enqueue(5);

            Assert.AreEqual(1, q.Dequeue());
        }
Exemplo n.º 3
0
        public void TestSingleNode()
        {
            Stack stackOne = new Stack(null);
            Stack stackTwo = new Stack(null);

            Node node1 = new Node(1);


            QueueOfStacks queue = new QueueOfStacks(stackOne, stackTwo);

            queue.Enqueue(node1);

            Assert.Equal(node1.Value, queue.Dequeue().Value);
        }
Exemplo n.º 4
0
        public void LastNodeAddedIsNotFirstOut()
        {
            Stack stackOne = new Stack(null);
            Stack stackTwo = new Stack(null);

            Node node1 = new Node(1);
            Node node2 = new Node(2);
            Node node3 = new Node(3);

            QueueOfStacks queue = new QueueOfStacks(stackOne, stackTwo);

            queue.Enqueue(node1);
            queue.Enqueue(node2);
            queue.Enqueue(node3);

            Assert.NotEqual(node3.Value, queue.Dequeue().Value);
        }
Exemplo n.º 5
0
        public void TestToRemoveFirstNodeAddedToQueue()
        {
            Stack stackOne = new Stack(null);
            Stack stackTwo = new Stack(null);

            Node node1 = new Node(1);
            Node node2 = new Node(2);
            Node node3 = new Node(3);

            QueueOfStacks queue = new QueueOfStacks(stackOne, stackTwo);

            queue.Enqueue(node1);
            queue.Enqueue(node2);
            queue.Enqueue(node3);

            Assert.Equal(node1.Value, queue.Dequeue().Value);
        }
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Stack stackOne = new Stack(null);
            Stack stackTwo = new Stack(null);

            Node node1 = new Node(1);
            Node node2 = new Node(2);
            Node node3 = new Node(3);

            QueueOfStacks queue = new QueueOfStacks(stackOne, stackTwo);

            queue.Enqueue(node1);
            queue.Enqueue(node2);
            queue.Enqueue(node3);

            Console.WriteLine($"Item dequeued: {queue.Dequeue().Value}");
        }