home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
jbuilder
/
jsamples.z
/
SList2.java
< prev
next >
Wrap
Text File
|
1997-07-30
|
1KB
|
48 lines
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
/**
* Counting, finding, erasing, replacing, removing.
*
* @see COM.objectspace.jgl.SList
* @version 2.0.2
* @author ObjectSpace, Inc.
*/
public class SList2
{
public static void main( String[] args )
{
SList list = new SList();
list.add( "ape" );
list.add( "bat" );
list.add( "cat" );
list.add( "bat" );
list.add( "bat" );
list.add( "cat" );
System.out.println( list );
System.out.println();
System.out.println( "list.count( bat ) = " + list.count( "bat" ) );
SListIterator iterator = list.find( "bat" );
if ( !iterator.atEnd() )
{
System.out.println( "object at list.find( bat ) = " + iterator.get() );
list.remove( iterator );
System.out.println( "After list.remove( iterator ) = " + list );
}
SListIterator start = list.begin();
SListIterator finish = list.begin();
finish.advance( 3 );
list.replace( start, finish, "bat", "BAT" );
System.out.println( "After list.replace( start, finish, bat, BAT ) = " + list );
System.out.println( "list.remove( cat ) = " + list.remove( "cat" ) );
System.out.println( "After list.remove( cat ) = " + list );
list.remove( list.begin() );
System.out.println( "After list.remove( begin() ) = " + list );
}
}