Esempio n. 1
0
        static void Main()
        {
            StackedQueue <int> s = new StackedQueue <int>();

            s.Enqueue(1);
            s.Enqueue(2);
            s.Enqueue(3);
            s.Print();
            s.Dequeue();
            s.Print();
            s.Dequeue();
            s.Print();
            s.Dequeue();
            s.Print();
        }
Esempio n. 2
0
        static void Main()
        {
            StackedQueue <int> s = new StackedQueue <int>();

            // Enqueue three items
            // Enqueue is O(2n), one itteration to fill stack, one to empty back on.
            s.Enqueue(1);
            s.Enqueue(2);
            s.Enqueue(3);

            s.Print();

            // Dequeue and print items.
            // Dequeue is O(1), pop operation.
            s.Dequeue();
            s.Print();
            s.Dequeue();
            s.Print();
            s.Dequeue();
            s.Print();
        }