All Packages  Class Hierarchy  Previous  Next  Index

Filling Examples

Filling 1 - Filling a sequence with a single element and multiple elements.


Filling1 Example Code

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

import COM.objectspace.jgl.*;

/**
 * Filling a sequence with a single element and multiple elements.
 *
 * @see COM.objectspace.jgl.Filling
 * @version 2.0.2
 * @author ObjectSpace, Inc.
 */

public class Filling1
  {
  public static void main( String[] args )
    {
    int intArray[] = new int[ 10 ];
    System.out.println( "Fill a native array of integers with 42" );
    IntIterator begin = IntIterator.begin( intArray );
    IntIterator end = IntIterator.end( intArray );
    Filling.fill( begin, end, new Integer( 42 ) );
    Printing.println( begin, end );
    System.out.println();

    Array array = new Array();
    array.add( "cat" );
    array.add( "dog" );
    array.add( "emu" );
    array.add( "fox" );
    System.out.println( "array = " + array );
    System.out.println( "Fill the array with gnu" );
    Filling.fill( array, "gnu" );
    System.out.println( "array = " + array );

    System.out.println( "Fill the first 3 elements with bat." );
    Filling.fillN( array.begin(), 3, "bat" );
    System.out.println( "array = " + array );
    }
  }

Filling1 Example Output

Fill a native array of integers with 42
( 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 )

array = Array( cat, dog, emu, fox )
Fill the array with gnu
array = Array( gnu, gnu, gnu, gnu )
Fill the first 3 elements with bat.
array = Array( bat, bat, bat, gnu )

All Packages  Class Hierarchy  Previous  Next  Index