home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
jbuilder
/
jsamples.z
/
OrderedSetOperations1.java
< prev
next >
Wrap
Text File
|
1997-07-30
|
2KB
|
52 lines
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
/**
* Union, intersection, difference, symmetric difference, inclusion.
*
* @see COM.objectspace.jgl.OrderedSetOperations
* @version 2.0.2
* @author ObjectSpace, Inc.
*/
public class OrderedSetOperations1
{
public static void main( String[] args )
{
OrderedSet set1 = new OrderedSet( new LessString() );
set1.add( "bat" );
set1.add( "dog" );
set1.add( "ape" );
OrderedSet set2 = new OrderedSet( new LessString() );
set2.add( "dog" );
set2.add( "ape" );
set2.add( "fox" );
System.out.println( "set1 = " + set1 + ", set2 = " + set2 );
OrderedSet union = new OrderedSet( new LessString() );
OrderedSetOperations.setUnion( set1, set2, new InsertIterator( union ), new LessString() );
System.out.println( "union = " + union );
System.out.println( "union = " + set1.union( set2 ) );
OrderedSet intersection = new OrderedSet( new LessString() );
OrderedSetOperations.setIntersection( set1, set2, new InsertIterator( intersection ), new LessString() );
System.out.println( "intersection = " + intersection );
System.out.println( "intersection = " + set1.intersection( set2 ) );
Array difference = new Array();
OrderedSetOperations.setDifference( set1, set2, new InsertIterator( difference ), new LessString() );
System.out.println( "difference = " + difference );
Array symDifference = new Array();
OrderedSetOperations.setSymmetricDifference( set1, set2, new InsertIterator( symDifference ), new LessString() );
System.out.println( "symmetric difference = " + symDifference );
boolean includes1 = OrderedSetOperations.includes( difference, symDifference, new LessString() );
System.out.println( "includes1 = " + includes1 );
boolean includes2 = OrderedSetOperations.includes( symDifference, difference, new LessString() );
System.out.println( "includes2 = " + includes2 );
}
}