Exemple #1
0
        static void Main()
        {
            MyQueue <int> numbers = new MyQueue <int>();

            for (int i = 1; i < 5; i++)
            {
                numbers.Enqueue(i);
            }
            int firstElement = numbers.Peek();

            Console.WriteLine(firstElement);

            // There is some bug with the dequeue that i need to find
            //numbers.Dequeue();

            try
            {
                foreach (var number in numbers)
                {
                    Console.WriteLine(number);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        public static void Main()
        {
            var queue = new MyQueue <int>(1);

            queue.Enqueue(3);
            queue.Enqueue(5);
            queue.Enqueue(4);

            Console.WriteLine(queue.Peek());
            Console.WriteLine(queue.Dequeue());
            Console.WriteLine(queue.Dequeue());
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var myQueue = new MyQueue <int>();

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

            Console.WriteLine(myQueue.Dequeue());
            Console.WriteLine(myQueue.Peek());
            Console.WriteLine(myQueue.Dequeue());

            Console.ReadLine();
        }