ucar.ma2.Array.isConstant()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(88)

本文整理了Java中ucar.ma2.Array.isConstant()方法的一些代码示例,展示了Array.isConstant()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Array.isConstant()方法的具体详情如下:
包路径:ucar.ma2.Array
类名称:Array
方法名:isConstant

Array.isConstant介绍

[英]If this is a constant array
[中]如果这是一个常量数组

代码示例

代码示例来源:origin: Unidata/thredds

/**
 * Cover for System.arraycopy(). Works with the underlying data arrays.
 * ArraySrc and ArrayDst must be the same primitive type.
 * Exposed for efficiency; use at your own risk.
 *
 * @param arraySrc copy from here : if not in canonical order, an extra copy will be done
 * @param srcPos   starting at
 * @param arrayDst copy to here : must be in canonical order
 * @param dstPos   starting at
 * @param len      number of elements to copy
 */
static public void arraycopy(Array arraySrc, int srcPos, Array arrayDst, int dstPos, int len) {
 // deal with special case
 if (arraySrc.isConstant()) {
  double d = arraySrc.getDouble(0);
  for (int i = dstPos; i < dstPos + len; i++)
   arrayDst.setDouble(i, d);
  return;
 }
 Object src = arraySrc.get1DJavaArray(arraySrc.getDataType()); // ensure canonical order
 Object dst = arrayDst.getStorage();
 System.arraycopy(src, srcPos, dst, dstPos, len);
}

代码示例来源:origin: edu.ucar/cdm

/**
 * Cover for System.arraycopy(). Works with the underlying data arrays.
 * ArraySrc and ArrayDst must be the same primitive type.
 * Exposed for efficiency; use at your own risk.
 *
 * @param arraySrc copy from here : if not in canonical order, an extra copy will be done
 * @param srcPos   starting at
 * @param arrayDst copy to here : must be in canonical order
 * @param dstPos   starting at
 * @param len      number of elements to copy
 */
static public void arraycopy(Array arraySrc, int srcPos, Array arrayDst, int dstPos, int len) {
 // deal with special case
 if (arraySrc.isConstant()) {
  double d = arraySrc.getDouble(0);
  for (int i = dstPos; i < dstPos + len; i++)
   arrayDst.setDouble(i, d);
  return;
 }
 Object src = arraySrc.get1DJavaArray(arraySrc.getElementType()); // ensure canonical order
 Object dst = arrayDst.getStorage();
 System.arraycopy(src, srcPos, dst, dstPos, len);
}

代码示例来源:origin: edu.ucar/netcdf

/**
 * Cover for System.arraycopy(). Works with the underlying data arrays.
 * ArraySrc and ArrayDst must be the same primitive type.
 * Exposed for efficiency; use at your own risk.
 *
 * @param arraySrc copy from here : if not in canonical order, an extra copy will be done
 * @param srcPos   starting at
 * @param arrayDst copy to here : must be in canonical order
 * @param dstPos   starting at
 * @param len      number of elements to copy
 */
static public void arraycopy(Array arraySrc, int srcPos, Array arrayDst, int dstPos, int len) {
 // deal with special case
 if (arraySrc.isConstant()) {
  double d = arraySrc.getDouble(0);
  for (int i=dstPos; i<dstPos+len; i++)
   arrayDst.setDouble(i, d); 
  return;
 }
 Object src = arraySrc.get1DJavaArray(arraySrc.getElementType()); // ensure canonical order
 Object dst = arrayDst.getStorage();
 try {
  System.arraycopy(src, srcPos, dst, dstPos, len);
 } catch (ArrayIndexOutOfBoundsException e) {
  throw e;
 }
}

相关文章

微信公众号

最新文章

更多