package asd_library.queue;

import java.util.*;

/**
 * Main class to show queue use.
 */

public class QueueDemo {
  /**
   * Calls the constructor and some methods.
   * @param args
   */
  public static void main(String[] args) {
    Queue q1 = new Queue();
    Queue q2;

    System.out.println("Queue Demo:");
    System.out.println("q1 "+  q1);

    for(int i = 1; i<=10; i++){
      q1.enqueue(new Integer(i));
    }
    q2 = (Queue)q1.clone();

    System.out.println("Queue Representation: first item at the head, last item at the end");
    System.out.println("q1 "+  q1);
    System.out.println("q2 "+  q2);
    System.out.println("q1.equals(q2): "+q1.equals(q2));
    System.out.print("q1==q2: "); System.out.println(q1==q2);
    System.out.println("first element in q1: "+q1.dequeue());
    System.out.println("q1 "+  q1);
    System.out.println("q2 "+  q2);
    System.out.println("q1.equals(q2): "+q1.equals(q2));

    System.out.print("Use Of ListIterator on q2: ");
    ListIterator li= q2.listIterator();
    while(li.hasNext())
      System.out.print(li.next()+ " ");





  }
}




 


Bacheca di Algoritmi e Strutture Dati a.a. 2007-08 - canale A - L

forum del corso

ultima modifica: 03/04/2008 23.35
by FdA