home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 October A / Pcwk10a98.iso / Inprise / TRIAL / JBUILDER / JSAMPLES.Z / Filling1.java < prev    next >
Text File  |  1998-05-08  |  1KB  |  41 lines

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2. import com.objectspace.jgl.*;
  3. import com.objectspace.jgl.adapters.*;
  4. import com.objectspace.jgl.algorithms.*;
  5.  
  6. /**
  7.  * Filling a sequence with a single element and multiple elements.
  8.  *
  9.  * @see com.objectspace.jgl.algorithms.Filling
  10.  * @version 3.0.0
  11.  * @author ObjectSpace, Inc.
  12.  */
  13.  
  14. public class Filling1
  15.   {
  16.   public static void main( String[] args )
  17.     {
  18.     int intArray[] = new int[ 10 ];
  19.     System.out.println( "Fill a native array of integers with 42" );
  20.     IntIterator begin = IntIterator.begin( intArray );
  21.     IntIterator end = IntIterator.end( intArray );
  22.     Filling.fill( begin, end, new Integer( 42 ) );
  23.     Printing.println( begin, end );
  24.     System.out.println();
  25.  
  26.     Array array = new Array();
  27.     array.add( "cat" );
  28.     array.add( "dog" );
  29.     array.add( "emu" );
  30.     array.add( "fox" );
  31.     System.out.println( "array = " + array );
  32.     System.out.println( "Fill the array with gnu" );
  33.     Filling.fill( array, "gnu" );
  34.     System.out.println( "array = " + array );
  35.  
  36.     System.out.println( "Fill the first 3 elements with bat." );
  37.     Filling.fillN( array.begin(), 3, "bat" );
  38.     System.out.println( "array = " + array );
  39.     }
  40.   }
  41.