Exemplo n.º 1
0
void TestQueue()
{
	Queue<int> q;
	q.Push(1);
	q.Push(2);
	q.Push(3);
	q.Push(4);

	q.Print();

	q.Pop();
	q.Pop();
	q.Pop();

	q.Print();
}
Exemplo n.º 2
0
int main()
{
    /*Driver Code to test the implementation
    Printing the elements in Queue after each Enqueue or Dequeue
    */
    Queue Q; // creating an instance of Queue.
    Q.Enqueue(2);
    Q.Print();
    Q.Enqueue(4);
    Q.Print();
    Q.Enqueue(6);
    Q.Print();
    Q.Dequeue();
    Q.Print();
    Q.Enqueue(8);
    Q.Print();
}
Exemplo n.º 3
0
int main() {
    Elem n1 = Elem(12, NULL);
    Elem n2 = Elem(99, NULL);
    Elem n3 = Elem(37, NULL);
    Queue q = Queue();

    q.Insert(n1);
    q.Insert(n2);
    q.Insert(n3);

    q.Print();

    Elem *n;
    while (!q.Empty()) {
        n = q.RemoveFirst();
        cout << "remove " << n->state << endl;
    }
}