static void Main(string[] args)
        {
            //test queue

            //create list
            LinkedList myList = new LinkedList();
            //create queue
            LLQueue myQueue = new LLQueue(myList);

            //enqueue 6 numbers
            Console.WriteLine("enqueue 6");
            myQueue.Enqueue(6);
            Console.WriteLine("enqueue 5");
            myQueue.Enqueue(5);
            Console.WriteLine("enqueue 4");
            myQueue.Enqueue(4);
            Console.WriteLine("enqueue 3");
            myQueue.Enqueue(3);
            Console.WriteLine("enqueue 2");
            myQueue.Enqueue(2);
            Console.WriteLine("enqueue 1");
            myQueue.Enqueue(1);
            //peek front to ensure that "6" is the first node in queue
            Console.WriteLine("Peek front: " + myQueue.Peek());

            //dequeue the first 3 nodes
            Console.WriteLine("Dequeue");
            Console.WriteLine("removed " + myQueue.Dequeue());
            Console.WriteLine("Dequeue");
            Console.WriteLine("removed " + myQueue.Dequeue());
            Console.WriteLine("Dequeue");
            Console.WriteLine("removed " + myQueue.Dequeue());

            //peek front again to ensure that "3" is now the front node
            Console.WriteLine("Peek Front: " + myQueue.Peek());
            Console.ReadKey();
        }
예제 #2
0
    static void Main()
    {
        LLQueue q = new LLQueue();

        q.Enqueue(123);
        q.Enqueue("lgslaya");
        q.Enqueue('f');
        q.Enqueue("Nodes R US");
        q.Enqueue(34.46);
        Console.WriteLine("Peek: " + q.Peek());
        Console.WriteLine(q.ToString());
        q.Dequeue();

        q.Dequeue();
        q.Dequeue();

        q.Dequeue();
        Console.WriteLine(q.ToString());
        q.Enqueue(1337);
        q.Enqueue("\'7th item");
        q.Enqueue("Should be wrapping around");
        q.Dequeue();
        Console.WriteLine(q.ToString());
    }