home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / inprise / JSAMPLES.Z / OrderedSet3.java < prev    next >
Text File  |  1998-05-08  |  1KB  |  44 lines

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2. import com.objectspace.jgl.*;
  3. import com.objectspace.jgl.predicates.*;
  4.  
  5. /**
  6.  * Union, intersection, difference, symmetric difference, subset.
  7.  *
  8.  * @see com.objectspace.jgl,OrderedSet
  9.  * @version 3.0.0
  10.  * @author ObjectSpace, Inc.
  11.  */
  12.  
  13. public class OrderedSet3
  14.   {
  15.   public static void main( String[] args )
  16.     {
  17.     OrderedSet set1 = new OrderedSet( new LessString() );
  18.     set1.add( "ape" );
  19.     set1.add( "cat" );
  20.     set1.add( "bat" );
  21.  
  22.     OrderedSet set2 = new OrderedSet();
  23.     set2.add( "bat" );
  24.     set2.add( "fox" );
  25.     set2.add( "ape" );
  26.     System.out.println( "set1 = " + set1 + ", set2 = " + set2 );
  27.  
  28.     OrderedSet set3 = set1.union( set2 );
  29.     System.out.println( "set3 = set1.union( set2 ) = " + set3 );
  30.  
  31.     OrderedSet set4 = set1.intersection( set2 );
  32.     System.out.println( "set4 = set1.intersection( set2 ) = " + set4 );
  33.  
  34.     OrderedSet set5 = set1.difference( set2 );
  35.     System.out.println( "set5 = set1.difference( set2 ) = " + set5 );
  36.  
  37.     OrderedSet set6 = set1.symmetricDifference( set2 );
  38.     System.out.println( "set6 = set1.symmetricDifference( set2 ) = " + set6 );
  39.  
  40.     System.out.println( "set4.subsetOf( set3 ) = " + set4.subsetOf( set3 ) );
  41.     System.out.println( "set3.subsetOf( set4 ) = " + set3.subsetOf( set4 ) );
  42.     }
  43.   }
  44.