cdm/src/main/java/ucar/ma2/MAMath.java
public static void copy(DataType dataType, IndexIterator from, IndexIterator to) throws IllegalArgumentException {
    if (dataType == DataType.DOUBLE) {
      while (from.hasNext())
        to.setDoubleNext(from.getDoubleNext());
    } else if (dataType == DataType.FLOAT) {
      while (from.hasNext())
        to.setFloatNext(from.getFloatNext());
    } else if (dataType.getPrimitiveClassType() == long.class) {
      while (from.hasNext())
        to.setLongNext(from.getLongNext());
    } else if (dataType.getPrimitiveClassType() == int.class) {
      while (from.hasNext())
        to.setIntNext(from.getIntNext());
    } else if (dataType.getPrimitiveClassType() == short.class) {
      while (from.hasNext())
        to.setShortNext(from.getShortNext());
    } else if (dataType == DataType.CHAR) {
      while (from.hasNext())
        to.setCharNext(from.getCharNext());
    } else if (dataType.getPrimitiveClassType() == byte.class) {
      while (from.hasNext())
        to.setByteNext(from.getByteNext());
    } else if (dataType == DataType.BOOLEAN) {
      while (from.hasNext())
        to.setBooleanNext(from.getBooleanNext());
    } else {
      while (from.hasNext())
        to.setObjectNext(from.getObjectNext());
    }
  }
public static void copy(DataType dataType, IndexIterator from, IndexIterator to) throws IllegalArgumentException {
    if (dataType == DataType.DOUBLE) {
      while (from.hasNext())
        to.setDoubleNext(from.getDoubleNext());
    } else if (dataType == DataType.FLOAT) {
      while (from.hasNext())
        to.setFloatNext(from.getFloatNext());
    } else if (dataType.getPrimitiveClassType() == long.class) {
      while (from.hasNext())
        to.setLongNext(from.getLongNext());
    } else if (dataType.getPrimitiveClassType() == int.class) {
      while (from.hasNext())
        to.setIntNext(from.getIntNext());
    } else if (dataType.getPrimitiveClassType() == short.class) {
      while (from.hasNext())
        to.setShortNext(from.getShortNext());
    } else if (dataType == DataType.CHAR) {
      while (from.hasNext())
        to.setCharNext(from.getCharNext());
    } else if (dataType.getPrimitiveClassType() == byte.class) {
      while (from.hasNext())
        to.setByteNext(from.getByteNext());
    } else if (dataType == DataType.BOOLEAN) {
      while (from.hasNext())
        to.setBooleanNext(from.getBooleanNext());
    } else {
      while (from.hasNext())
        to.setObjectNext(from.getObjectNext());
    }
  }
public static void copy ( DataType dataType , IndexIterator from , IndexIterator to ) throws IllegalArgumentException { if ( dataType == DataType . DOUBLE ) { while ( from . hasNext ( ) ) to . setDoubleNext ( from . getDoubleNext ( ) ) ; } else if ( dataType == DataType . FLOAT ) { while ( from . hasNext ( ) ) to . setFloatNext ( from . getFloatNext ( ) ) ; } else if ( dataType . getPrimitiveClassType ( ) == long . class ) { while ( from . hasNext ( ) ) to . setLongNext ( from . getLongNext ( ) ) ; } else if ( dataType . getPrimitiveClassType ( ) == int . class ) { while ( from . hasNext ( ) ) to . setIntNext ( from . getIntNext ( ) ) ; } else if ( dataType . getPrimitiveClassType ( ) == short . class ) { while ( from . hasNext ( ) ) to . setShortNext ( from . getShortNext ( ) ) ; } else if ( dataType == DataType . CHAR ) { while ( from . hasNext ( ) ) to . setCharNext ( from . getCharNext ( ) ) ; } else if ( dataType . getPrimitiveClassType ( ) == byte . class ) { while ( from . hasNext ( ) ) to . setByteNext ( from . getByteNext ( ) ) ; } else if ( dataType == DataType . BOOLEAN ) { while ( from . hasNext ( ) ) to . setBooleanNext ( from . getBooleanNext ( ) ) ; } else { while ( from . hasNext ( ) ) to . setObjectNext ( from . getObjectNext ( ) ) ; } }
Copy using iterators. Will copy until !from.hasNext().

@param dataType use this operation type (eg DataType.DOUBLE uses getDoubleNext())
@param from     copy from here
@param to       copy to here
@throws IllegalArgumentException      a and b are not conformable
@throws UnsupportedOperationException dont support this data type
Copy using iterators . Will copy until !from . hasNext () .