All Packages  Class Hierarchy  Previous  Next  Index

Permuting Examples

Permuting 1 - Creating permutations of an JGL container and a native array of Objects.


Permuting1 Example Code

// Copyright(c) 1996,1997 ObjectSpace, Inc.

import COM.objectspace.jgl.*;

/**
 * Creating permutations of an JGL container and a native array of Objects.
 *
 * @see COM.objectspace.jgl.Permuting
 * @version 2.0.2
 * @author ObjectSpace, Inc.
 */

public class Permuting1
  {
  public static void main( String[] args )
    {
    Array array = new Array();
    array.add( new Integer( 0 ) );
    array.add( new Integer( 2 ) );
    array.add( new Integer( 5 ) );
    do
      {
      System.out.println( "array = " + array );
      }
    while ( Permuting.nextPermutation( array, new LessNumber() ) );

    String[] strings = { "gnu", "emu", "dog" };
    ObjectArray strArray = new ObjectArray( strings );
    do
      {
      System.out.println( strArray );
      }
    while ( Permuting.prevPermutation( strArray, new LessString() ) );
    }
  }

Permuting1 Example Output

array = Array( 0, 2, 5 )
array = Array( 0, 5, 2 )
array = Array( 2, 0, 5 )
array = Array( 2, 5, 0 )
array = Array( 5, 0, 2 )
array = Array( 5, 2, 0 )
Object[]( gnu, emu, dog )
Object[]( gnu, dog, emu )
Object[]( emu, gnu, dog )
Object[]( emu, dog, gnu )
Object[]( dog, gnu, emu )
Object[]( dog, emu, gnu )

All Packages  Class Hierarchy  Previous  Next  Index