home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
jbuilder
/
jsamples.z
/
DList2.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.DList
* @version 2.0.2
* @author ObjectSpace, Inc.
*/
public class DList2
{
public static void main( String[] args )
{
DList dlist = new DList();
dlist.add( "ape" );
dlist.add( "bat" );
dlist.add( "cat" );
dlist.add( "bat" );
dlist.add( "bat" );
dlist.add( "cat" );
System.out.println( dlist );
System.out.println();
System.out.println( "dlist.count( bat ) = " + dlist.count( "bat" ) );
DListIterator iterator = dlist.find( "bat" );
if ( !iterator.atEnd() )
{
System.out.println( "object at dlist.find( bat ) = " + iterator.get() );
dlist.remove( iterator );
System.out.println( "After dlist.remove( iterator ) = " + dlist );
}
DListIterator start = dlist.begin();
DListIterator finish = dlist.begin();
finish.advance( 3 );
dlist.replace( start, finish, "bat", "BAT" );
System.out.println( "After dlist.replace( start, finish, bat, BAT ) = " + dlist );
System.out.println( "dlist.remove( cat ) = " + dlist.remove( "cat" ) );
System.out.println( "After dlist.remove( cat ) = " + dlist );
dlist.remove( dlist.begin() );
System.out.println( "After dlist.remove( begin() ) = " + dlist );
}
}