SList1public class SList1 extends Object Construction, enumeration, access, pushing, popping. |
Methods Summary |
---|
public static void | main(java.lang.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 );
|
|