FileDocCategorySizeDatePackage
Algorithms6.javaAPI DocExample1185Sat Sep 12 03:01:00 BST 1998None

Algorithms6

public class Algorithms6 extends Object
Replacing provides algorithms for substituting elements in a container.
see
com.objectspace.jgl.algorithms.Replacing
version
3.0.0
author
ObjectSpace, Inc.

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    DList list = new DList();
    list.add( new Integer( -1 ) );
    list.add( new Integer( 1 ) );
    list.add( new Integer( -2 ) );
    list.add( new Integer( 1 ) );
    list.add( new Integer( -3 ) );
    System.out.println( "list = " + list );

    Object oldValue = new Integer( 1 );
    Object newValue = new Integer( 4 );
    int n1 = Replacing.replace( list, oldValue, newValue );
    System.out.println( "after 1 -> 4, list = " + list );

    Array array = new Array();
    UnaryPredicate predicate = new NegativeNumber();
    newValue = new Integer( 0 );
    Replacing.replaceCopyIf( list, array, predicate, newValue );
    System.out.println( "list = " + list );
    System.out.println( "array = " + array );