static void Main(string[] args)
        {
            var strings = new LinkedQueue <string>();

            strings.Enqueue("First GrandMa");
            strings.Enqueue("Second GrandMa");
            strings.Enqueue("Third GrandMa");
            strings.Enqueue("Fourhth GrandMa");

            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine("{0} count: {1}", strings.Dequeue(), strings.Count);
            }

            //var outOfQueue = strings.Dequeue(); //exception
        }
Example #2
0
        public static void Main()
        {
            var queue = new LinkedQueue <int>();

            new List <int> {
                1, 2, 3, 4, 5
            }.ForEach(x => queue.Enqueue(x));

            while (queue.Count > 0)
            {
                Console.WriteLine(queue.Dequeue());
            }
        }
        public static void Main()
        {
            LinkedQueue <int> customQueue = new LinkedQueue <int>();

            for (int i = 0; i < 50; i++)
            {
                customQueue.Enqueue(i);
            }

            Console.WriteLine("Items in the custom queue:");
            while (customQueue.Head != null)
            {
                Console.Write("{0} ", customQueue.Dequeue());
            }

            Console.WriteLine();
        }
        public static void Main()
        {
            var queue   = new Queue <int>();
            var myQueue = new LinkedQueue <int>();

            for (int i = 0; i < 20; i++)
            {
                queue.Enqueue(i);
                myQueue.Enqueue(i);
            }

            for (int i = 0; i < 10; i++)
            {
                queue.Dequeue();
                myQueue.Dequeue();
            }

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

            Console.WriteLine(string.Join(", ", queue));
            Console.WriteLine(string.Join(", ", myQueue));
        }