FileDocCategorySizeDatePackage
Stacks4.javaAPI DocExample1105Sat Sep 12 03:01:00 BST 1998None

Stacks4

public class Stacks4 extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    // Use a HashComparator for comparing elements. Since the hash value of an
    // Integer is its int value, this will order Integers in descending order.
    PriorityQueue queue = new PriorityQueue();
    queue.push( new Integer( 5 ) );
    queue.push( new Integer( -2 ) );
    queue.push( new Integer( 10 ) );
    queue.push( new Integer( 6 ) );
    queue.push( new Integer( 20 ) );
    queue.push( new Integer( -10 ) );

    System.out.println( "queue = " + queue );
    System.out.println();

    System.out.println( "Non-destructively enumerate the PriorityQueue." );
    Enumeration e = queue.elements();
    while ( e.hasMoreElements() )
      System.out.print( e.nextElement() + " " );
    System.out.println();

    System.out.println( "Pop and print each element." );
    while ( !queue.isEmpty() )
      System.out.print( queue.pop() + " " );
    System.out.println();