scala.actors.threadpool.Arrays.copyOf()方法的使用及代码示例

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

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

Arrays.copyOf介绍

暂无

代码示例

代码示例来源:origin: org.scala-lang/scala-actors

/**
 * @since 1.6
 */
public static Object[] copyOf(Object[] original, int newLength) {
  return copyOf(original, newLength, original.getClass());
}

代码示例来源:origin: org.scala-lang.virtualized/scala-actors

/**
 * @since 1.6
 */
public static Object[] copyOf(Object[] original, int newLength) {
  return copyOf(original, newLength, original.getClass());
}

代码示例来源:origin: org.scala-lang/scala-actors

public static Object[] collectionToArray(Collection c) {
  // guess the array size; expect to possibly be different
  int len = c.size();
  Object[] arr = new Object[len];
  Iterator itr = c.iterator();
  int idx = 0;
  while (true) {
    while (idx < len && itr.hasNext()) {
      arr[idx++] = itr.next();
    }
    if (!itr.hasNext()) {
      if (idx == len) return arr;
      // otherwise have to trim
      return Arrays.copyOf(arr, idx, Object[].class);
    }
    // otherwise, have to grow
    int newcap = ((arr.length/2)+1)*3;
    if (newcap < arr.length) {
      // overflow
      if (arr.length < Integer.MAX_VALUE) {
        newcap = Integer.MAX_VALUE;
      }
      else {
        throw new OutOfMemoryError("required array size too large");
      }
    }
    arr = Arrays.copyOf(arr, newcap, Object[].class);
    len = newcap;
  }
}

代码示例来源:origin: org.scala-lang.virtualized/scala-actors

public static Object[] collectionToArray(Collection c) {
  // guess the array size; expect to possibly be different
  int len = c.size();
  Object[] arr = new Object[len];
  Iterator itr = c.iterator();
  int idx = 0;
  while (true) {
    while (idx < len && itr.hasNext()) {
      arr[idx++] = itr.next();
    }
    if (!itr.hasNext()) {
      if (idx == len) return arr;
      // otherwise have to trim
      return Arrays.copyOf(arr, idx, Object[].class);
    }
    // otherwise, have to grow
    int newcap = ((arr.length/2)+1)*3;
    if (newcap < arr.length) {
      // overflow
      if (arr.length < Integer.MAX_VALUE) {
        newcap = Integer.MAX_VALUE;
      }
      else {
        throw new OutOfMemoryError("required array size too large");
      }
    }
    arr = Arrays.copyOf(arr, newcap, Object[].class);
    len = newcap;
  }
}

代码示例来源:origin: org.scala-lang.virtualized/scala-actors

return Arrays.copyOf(arr, idx, aType);
arr = Arrays.copyOf(arr, newcap, aType);
len = newcap;

代码示例来源:origin: org.scala-lang/scala-actors

return Arrays.copyOf(arr, idx, aType);
arr = Arrays.copyOf(arr, newcap, aType);
len = newcap;

代码示例来源:origin: openimaj/openimaj

@Override
  public void perform(File f) {
    final Matrix basis = pca.getBasis();
    final Matrix tmp = new Matrix(1, 128);
    if (f.getName().endsWith(".bin")) {
      try {
        System.out.println("Processing " + f);
        final MemoryLocalFeatureList<FloatDSIFTKeypoint> feats = MemoryLocalFeatureList.read(f,
            FloatDSIFTKeypoint.class);
        final File outfile = new File(outdir, f.getAbsolutePath().replace(
            indir.getAbsolutePath(), ""));
        outfile.getParentFile().mkdirs();
        for (final FloatDSIFTKeypoint kpt : feats) {
          tmp.getArray()[0] = ArrayUtils.convertToDouble(kpt.descriptor);
          final double[] proj = tmp.times(basis).getArray()[0];
          kpt.descriptor = ArrayUtils.convertToFloat(proj);
          kpt.descriptor = Arrays.copyOf(kpt.descriptor, kpt.descriptor.length + 2);
          kpt.descriptor[kpt.descriptor.length - 2] = (kpt.x / 125f) - 0.5f;
          kpt.descriptor[kpt.descriptor.length - 1] = (kpt.y / 160f) - 0.5f;
        }
        IOUtils.writeBinary(outfile, feats);
        f.delete();
      } catch (final Exception e) {
      }
    }
  }
});

代码示例来源:origin: org.openimaj/sandbox

@Override
  public void perform(File f) {
    final Matrix basis = pca.getBasis();
    final Matrix tmp = new Matrix(1, 128);
    if (f.getName().endsWith(".bin")) {
      try {
        System.out.println("Processing " + f);
        final MemoryLocalFeatureList<FloatDSIFTKeypoint> feats = MemoryLocalFeatureList.read(f,
            FloatDSIFTKeypoint.class);
        final File outfile = new File(outdir, f.getAbsolutePath().replace(
            indir.getAbsolutePath(), ""));
        outfile.getParentFile().mkdirs();
        for (final FloatDSIFTKeypoint kpt : feats) {
          tmp.getArray()[0] = ArrayUtils.convertToDouble(kpt.descriptor);
          final double[] proj = tmp.times(basis).getArray()[0];
          kpt.descriptor = ArrayUtils.convertToFloat(proj);
          kpt.descriptor = Arrays.copyOf(kpt.descriptor, kpt.descriptor.length + 2);
          kpt.descriptor[kpt.descriptor.length - 2] = (kpt.x / 125f) - 0.5f;
          kpt.descriptor[kpt.descriptor.length - 1] = (kpt.y / 160f) - 0.5f;
        }
        IOUtils.writeBinary(outfile, feats);
        f.delete();
      } catch (final Exception e) {
      }
    }
  }
});

代码示例来源:origin: openimaj/openimaj

descriptor = Arrays.copyOf(descriptor, nf + 2);
descriptor[nf] = (kp.x / 125f) - 0.5f;
descriptor[nf + 1] = (kp.y / 160f) - 0.5f;

代码示例来源:origin: org.openimaj/sandbox

descriptor = Arrays.copyOf(descriptor, nf + 2);
descriptor[nf] = (kp.x / 125f) - 0.5f;
descriptor[nf + 1] = (kp.y / 160f) - 0.5f;

相关文章