public void VerifyPushInQueue()
        {
            var actual = new QueueUsingArray(3);

            actual.Enqueue(12);
            actual.Enqueue(14);
            actual.Enqueue(16);

            Assert.AreEqual(3, actual.Count());
        }
예제 #2
0
        public void Enqueue()
        {
            QueueUsingArray <int> queue = new QueueUsingArray <int>();

            queue.Enqueue(10);
            queue.Enqueue(20);
            queue.Enqueue(30);
            queue.Enqueue(40);

            //10 <- 20 <- 30 <- 40


            Assert.AreEqual(queue.Count, 4);
        }
        public void VerifyPeekInQueue()
        {
            var actual = new QueueUsingArray(3);

            actual.Enqueue(12);
            actual.Enqueue(14);
            actual.Enqueue(16);

            Assert.AreEqual(3, actual.Count());

            var value = actual.Peek();

            Assert.AreEqual(12, value);
            Assert.AreEqual(3, actual.Count());
        }
예제 #4
0
        public void Peek()
        {
            QueueUsingArray <int> queue = new QueueUsingArray <int>();

            queue.Enqueue(10);
            queue.Enqueue(20);
            queue.Enqueue(30);
            queue.Enqueue(40);

            //10 <- 20 <- 30 <- 40

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

            //30 <- 40


            Assert.AreEqual(queue.Peek(), 30);
        }
예제 #5
0
        static void Main(string[] args)
        {
            #region LinkedList
            SingleLinkedList <int>     singleLL = new SingleLinkedList <int>();
            SingleLinkedListNode <int> snode1   = new SingleLinkedListNode <int>(20);
            singleLL.AddFirst(snode1); singleLL.Add(30); singleLL.AddLast(90); singleLL.AddFirst(11);
            singleLL.PrintList("");

            DoubleLinkedList <int>     doubleLL = new DoubleLinkedList <int>();
            DoubleLinkedListNode <int> node1    = new DoubleLinkedListNode <int>(45);
            doubleLL.AddFirst(node1); doubleLL.AddLast(90); doubleLL.Add(33); doubleLL.Add(30); doubleLL.Add(31);
            doubleLL.PrintList("");

            #endregion

            #region Stack
            // To Evaluate PostFix Expression.
            PostFixCalculator();
            #endregion

            #region Queue
            QueueUsingArray <int> queue1 = new QueueUsingArray <int>();
            queue1.Enqueue(50); queue1.Enqueue(60); queue1.Enqueue(70); queue1.Enqueue(80); queue1.Enqueue(90);
            queue1.Dequeue(); queue1.Dequeue();
            queue1.Enqueue(50); queue1.Enqueue(60); queue1.Enqueue(70); queue1.Enqueue(80); queue1.Enqueue(90);
            queue1.Dequeue(); queue1.Dequeue();
            queue1.PrintQueue();

            QueueUsingList <int> queue2 = new QueueUsingList <int>();
            queue2.Enqueue(50); queue2.Enqueue(60); queue2.Enqueue(70); queue2.Enqueue(80); queue2.Enqueue(90);
            queue2.Dequeue(); queue2.Dequeue();
            queue2.Enqueue(50); queue2.Enqueue(60); queue2.Enqueue(70); queue2.Enqueue(80); queue2.Enqueue(90);
            queue2.Dequeue(); queue2.Dequeue();
            queue2.PrintQueue();
            #endregion

            #region Trees



            #endregion
        }