home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
jbuilder
/
jsamples.z
/
Queue1.java
< prev
next >
Wrap
Text File
|
1997-07-30
|
976b
|
39 lines
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import java.util.Enumeration;
import COM.objectspace.jgl.*;
/**
* Construction, enumeration, pushing, popping.
*
* @see COM.objectspace.jgl.Queue
* @version 2.0.2
* @author ObjectSpace, Inc.
*/
public class Queue1
{
public static void main( String[] args )
{
// Use an SList as the underlying data structure.
Queue queue = new Queue();
queue.push( "bat" );
queue.push( "cat" );
queue.push( "dog" );
System.out.println( "Print the Queue." );
System.out.println( queue );
System.out.println();
System.out.println( "Non-destructively enumerate the Queue." );
Enumeration e = queue.elements();
while ( e.hasMoreElements() )
System.out.println( e.nextElement() );
System.out.println();
System.out.println( "Pop and print each element." );
while ( !queue.isEmpty() )
System.out.println( queue.pop() );
}
}