Exemple #1
0
        private static void QueTest_Integer()/*The method that instantiates an integer queue,
                                              * displays items, the last node value, and the minimum value in the queue.*/
        {
            QueueInheritance <int> intQueue = new QueueInheritance <int>();

            for (int i = 0; i < intArray().Length; i++)
            {
                intQueue.Enqueue(intArray()[i]);
            }
            intQueue.Display();
            Console.WriteLine($"The last value of this que is {intQueue.GetLastNode()}");
            Console.WriteLine($"The minimum value of this que is {intQueue.Minimum()}");
        }
Exemple #2
0
        private static void QueTest_Double()/*The method that instantiates an double queue,
                                             * displays items, the last node value, and the minimum value in the queue.*/
        {
            QueueInheritance <double> doubleQueue = new QueueInheritance <double>();

            for (int i = 0; i < doubleArray().Length; i++)
            {
                doubleQueue.Enqueue(doubleArray()[i]);
            }
            doubleQueue.Display();
            Console.WriteLine($"The last value of this que is {doubleQueue.GetLastNode()}");
            Console.WriteLine($"The minimum value of this que is {doubleQueue.Minimum()}");
        }
Exemple #3
0
        static void Main(string[] args)
        {
            #region integerQueue
            // Create a queue of integers
            var integerQueue = new QueueInheritance <int>();

            // Populate values
            integerQueue.Enqueue(42);
            integerQueue.Enqueue(51);
            integerQueue.Enqueue(15);
            integerQueue.Enqueue(33);
            integerQueue.Enqueue(24);

            // Print a queue
            integerQueue.Display();

            // Get last node value
            Console.WriteLine("Last element in integer queue is " + integerQueue.GetLast());
            Console.WriteLine("--------------------------------------------------");
            #endregion

            #region doubleQueue
            // Create a queue of doubles
            var doubleQueue = new QueueInheritance <double>();

            // Populate values
            doubleQueue.Enqueue(42.2);
            doubleQueue.Enqueue(51.1);
            doubleQueue.Enqueue(15.5);
            doubleQueue.Enqueue(33.3);
            doubleQueue.Enqueue(24.4);

            // Print a queue
            doubleQueue.Display();

            // Get last node value
            Console.WriteLine("Last element of double queue is " + doubleQueue.GetLast());
            Console.WriteLine("--------------------------------------------------");
            #endregion

            #region MinumumValue
            // Get minumum node value
            Console.WriteLine("The minimum value of integer queue is " + integerQueue.Minimum());
            Console.WriteLine("--------------------------------------------------");
            Console.WriteLine("The minimum value of double queue is " + doubleQueue.Minimum());
            Console.WriteLine("--------------------------------------------------");
            #endregion
        } // end Main