home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
jbuilder
/
jsamples.z
/
OrderedSet4.java
< prev
next >
Wrap
Text File
|
1997-07-30
|
1KB
|
37 lines
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
/**
* Counting, finding, erasing.
*
* @see COM.objectspace.jgl.OrderedSet
* @version 2.0.2
* @author ObjectSpace, Inc.
*/
public class OrderedSet4
{
public static void main( String[] args )
{
OrderedSet set = new OrderedSet( new LessString() );
set.add( "cat" );
set.add( "ape" );
set.add( "dog" );
set.add( "bat" );
System.out.println( set );
System.out.println( "set.count( dog ) = " + set.count( "dog" ) );
OrderedSetIterator i = set.find( "dog" );
if ( i.equals( set.end() ) ) // A simpler way: if ( i.atEnd() ) ...
System.out.println( "Could not find dog." );
else
System.out.println( "Found " + i.get() );
System.out.println( "set.remove( dog ) = " + set.remove( "dog" ) );
OrderedSetIterator j = set.find( "dog" );
if ( j.atEnd() ) // A simpler way: if ( j.equals( set.end() ) ) ...
System.out.println( "Could not find dog." );
else
System.out.println( "Found " + j.get() );
}
}