FileDocCategorySizeDatePackage
Stacks5.javaAPI DocExample719Sat Sep 12 03:01:00 BST 1998None

Stacks5

public class Stacks5 extends Object

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

    // Use a GreaterString function object for comparing elements. This will
    // order strings in ascending order.
    PriorityQueue queue = new PriorityQueue( new GreaterString() );
    queue.push( "cat" );
    queue.push( "dog" );
    queue.push( "ape" );
    queue.push( "bat" );
    queue.push( "fox" );
    queue.push( "emu" );

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