home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / OrderedSetOperations1.java < prev    next >
Text File  |  1997-07-30  |  2KB  |  52 lines

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2.  
  3. import COM.objectspace.jgl.*;
  4.  
  5. /**
  6.  * Union, intersection, difference, symmetric difference, inclusion.
  7.  *
  8.  * @see COM.objectspace.jgl.OrderedSetOperations
  9.  * @version 2.0.2
  10.  * @author ObjectSpace, Inc.
  11.  */
  12.  
  13. public class OrderedSetOperations1
  14.   {
  15.   public static void main( String[] args )
  16.     {
  17.     OrderedSet set1 = new OrderedSet( new LessString() );
  18.     set1.add( "bat" );
  19.     set1.add( "dog" );
  20.     set1.add( "ape" );
  21.     OrderedSet set2 = new OrderedSet( new LessString() );
  22.     set2.add( "dog" );
  23.     set2.add( "ape" );
  24.     set2.add( "fox" );
  25.     System.out.println( "set1 = " + set1 + ", set2 = " + set2 );
  26.  
  27.     OrderedSet union = new OrderedSet( new LessString() );
  28.     OrderedSetOperations.setUnion( set1, set2, new InsertIterator( union ), new LessString() );
  29.     System.out.println( "union = " + union );
  30.     System.out.println( "union = " + set1.union( set2 ) );
  31.  
  32.     OrderedSet intersection = new OrderedSet( new LessString() );
  33.     OrderedSetOperations.setIntersection( set1, set2, new InsertIterator( intersection ), new LessString() );
  34.     System.out.println( "intersection = " + intersection );
  35.     System.out.println( "intersection = " + set1.intersection( set2 ) );
  36.  
  37.     Array difference = new Array();
  38.     OrderedSetOperations.setDifference( set1, set2, new InsertIterator( difference ), new LessString() );
  39.     System.out.println( "difference = " + difference );
  40.  
  41.     Array symDifference = new Array();
  42.     OrderedSetOperations.setSymmetricDifference( set1, set2, new InsertIterator( symDifference ), new LessString() );
  43.     System.out.println( "symmetric difference = " + symDifference );
  44.  
  45.     boolean includes1 = OrderedSetOperations.includes( difference, symDifference, new LessString() );
  46.     System.out.println( "includes1 = " + includes1 );
  47.  
  48.     boolean includes2 = OrderedSetOperations.includes( symDifference, difference, new LessString() );
  49.     System.out.println( "includes2 = " + includes2 );
  50.     }
  51.   }
  52.