home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / examples / sets4.java < prev    next >
Encoding:
Java Source  |  1996-07-14  |  821 b   |  27 lines

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. import jgl.*;
  3.  
  4. public class Sets4
  5.   {
  6.   public static void main( String[] args )
  7.     {
  8.     // Order key-value pairs in descending lexicographical order of keys.
  9.     // Note that "1" comes before "5".
  10.     OrderedSet set = new OrderedSet( new GreaterString(), true ); // Allow dups.
  11.     set.add( "10" );
  12.     set.add( "10" );
  13.     set.add( "5" );
  14.     set.add( "5" );
  15.     
  16.     System.out.println( "set = " + set );
  17.     int n = set.count( "10" );  
  18.     System.out.println( "There are " + n + " objects that match 10" );
  19.  
  20.     System.out.println( "Removing all occurrences of 10..." );
  21.     set.remove( "10" );
  22.  
  23.     n = set.count( "10" );
  24.     System.out.println( "There are now " + n + " objects that match 10" );
  25.     System.out.println( "set = " + set );
  26.     }
  27.   }