All Packages  Class Hierarchy  Previous  Next  Index

Copying Examples

Copying 1 - Copying a JGL container into another JGL container and standard output, backwards copying.


Copying1 Example Code

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

import COM.objectspace.jgl.*;

/**
 * Copying a JGL container into another JGL container and standard output, backwards copying.
 *
 * @see COM.objectspace.jgl.Copying
 * @version 2.0.2
 * @author ObjectSpace, Inc.
 */

public class Copying1
  {
  public static void main( String[] args )
    {
    Array array = new Array();
    array.add( new Integer( 3 ) );
    array.add( new Integer( 6 ) );
    array.add( new Integer( 4 ) );
    array.add( new Integer( 1 ) );
    Deque deque = new Deque();
    ArrayIterator start = array.begin();
    start.advance( 1 );
    ArrayIterator finish = array.end();
    finish.retreat( 1 );
    Copying.copy( start, finish, new InsertIterator( deque ) );
    System.out.println( "array = " + array + ", deque = " + deque );

    System.out.println( "Copy array to System.out." );
    Copying.copy( array, new OutputStreamIterator() );
    System.out.println();

    // To perform a forward copy when there is overlap, use copyBackward().
    Copying.copyBackward( start, finish, array.end() );
    System.out.println( "array = " + array );
    }
  }

Copying1 Example Output

array = Array( 3, 6, 4, 1 ), deque = Deque( 6, 4 )
Copy array to System.out.
3 6 4 1 
array = Array( 3, 6, 6, 4 )

All Packages  Class Hierarchy  Previous  Next  Index