public _004_DeQueue_On_BaseArray()
        {
            DeQue <int> instance = new DeQue <int>();
            bool        forTest  = true;

            if (forTest)
            {
                instance.EnqueueLast(1);
                instance.EnqueueLast(2);
                instance.EnqueueLast(3);
                instance.EnqueueLast(4);
                instance.EnqueueLast(5);
                instance.EnqueueLast(6);
                instance.EnqueueLast(7);
                instance.EnqueueLast(8);
                instance.EnqueueLast(9);
                instance.EnqueueLast(10);

                instance.EnqueueFirst(11);
                instance.EnqueueFirst(12);
                instance.EnqueueFirst(13);
                instance.EnqueueFirst(14);
                instance.EnqueueFirst(15);
                instance.EnqueueFirst(16);
                instance.EnqueueFirst(17);
                instance.EnqueueFirst(18);
                instance.EnqueueFirst(19);
                instance.EnqueueFirst(20);

                for (int i = 0; i < 10; i++)
                {
                    Console.WriteLine("DeQueueFirst {0}", instance.DeQueueFirst());
                }

                for (int i = 0; i < 10; i++)
                {
                    Console.WriteLine("_____DeQueueLast {0}", instance.DeQueueLast());
                }

                Console.WriteLine("PeekFirst {0}", instance.PeekFirst());
            }
            else
            {
                instance.EnqueueFirst(6);
                instance.EnqueueFirst(7);
                instance.EnqueueFirst(8);

                Console.WriteLine("PeekFirst {0}", instance.PeekFirst());

                instance.EnqueueFirst(6);
                instance.EnqueueFirst(7);
                instance.EnqueueFirst(8);

                Console.WriteLine("PeekFirst {0}", instance.PeekFirst());
                Console.WriteLine("PeekLast {0}", instance.PeekLast());
            }
        }
Example #2
0
        public _002_DeQueue()
        {
            DeQue <int> instance = new DeQue <int>();


            instance.EnqueueLast(1);
            instance.EnqueueLast(2);
            instance.EnqueueLast(3);
            instance.EnqueueLast(4);

            instance.EnqueueFirst(7);
            instance.EnqueueFirst(8);

            Console.WriteLine(instance.PeekFirst());
            Console.WriteLine(instance.PeekLast());
        }