home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-07-30 | 1.6 KB | 54 lines |
- // Copyright(c) 1996,1997 ObjectSpace, Inc.
-
- import java.util.Enumeration;
- import COM.objectspace.jgl.*;
-
- /**
- * Construction, enumeration, access, pushing, popping.
- *
- * @see COM.objectspace.jgl.SListist
- * @version 2.0.2
- * @author ObjectSpace, Inc.
- */
-
- public class SList1
- {
- public static void main( String[] args )
- {
- SList list = new SList();
- list.pushBack( "bat" );
- list.add( "cat" );
- list.pushFront( "ape" );
- System.out.println( list );
- System.out.println();
-
- System.out.println( "Enumerate the SList" );
- Enumeration e = list.elements();
- while ( e.hasMoreElements() )
- System.out.println( e.nextElement() );
- System.out.println();
-
- System.out.println( "Iterate through the SList" );
- for ( SListIterator i = list.begin(); !i.equals( list.end() ); i.advance() )
- System.out.println( i.get() );
- System.out.println();
-
- System.out.println( "Demonstrate access" );
- System.out.println( "list.at( 0 ) = " + list.at( 0 ) );
- System.out.println( "list.front() = " + list.front() );
- System.out.println( "list.at( 2 ) = " + list.at( 2 ) );
- System.out.println( "list.back() = " + list.back() );
- System.out.println();
-
- System.out.println( "Demonstrate modification" );
- list.put( 1, "fox" );
- System.out.println( list );
-
- System.out.println( "popFront() returns: " + list.popFront() );
- System.out.println( "After popFront() = " + list );
-
- System.out.println( "popBack() returns: " + list.popBack() );
- System.out.println( "After popBack() = " + list );
- }
- }
-