home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / jgl_1_1.exe / examples / Algorithms6.java < prev    next >
Encoding:
Java Source  |  1996-09-12  |  892 b   |  30 lines

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. import jgl.*;
  3.  
  4. public class Algorithms6
  5.   {
  6.   public static void main( String[] args )
  7.     {
  8.     DList list = new DList();
  9.     list.add( new Integer( -1 ) );
  10.     list.add( new Integer( 1 ) );
  11.     list.add( new Integer( -2 ) );
  12.     list.add( new Integer( 1 ) );
  13.     list.add( new Integer( -3 ) );
  14.     System.out.println( "list = " + list );
  15.  
  16.     Object oldValue = new Integer( 1 );
  17.     Object newValue = new Integer( 4 );
  18.     int n1 = Replacing.replace( list, oldValue, newValue );
  19.     System.out.println( "after 1 -> 4, list = " + list );
  20.  
  21.     Array array = new Array();
  22.     UnaryPredicate predicate = new NegativeInteger();
  23.     newValue = new Integer( 0 );
  24.     Replacing.replaceCopyIf( list, array, predicate, newValue );
  25.     System.out.println( "list = " + list );
  26.     System.out.println( "array = " + array );
  27.     }
  28.   }
  29.  
  30.