java.util.stream.DoubleStream.generate()方法的使用及代码示例

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

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

DoubleStream.generate介绍

暂无

代码示例

代码示例来源:origin: spinnaker/kayenta

List<Double> padding =
 DoubleStream
  .generate(() -> Double.NaN)
  .limit(offset)
  .boxed()

代码示例来源:origin: one.util/streamex

/**
 * Returns an infinite sequential unordered stream where each element is
 * generated by the provided {@code DoubleSupplier}. This is suitable for
 * generating constant streams, streams of random elements, etc.
 *
 * @param s the {@code DoubleSupplier} for generated elements
 * @return a new infinite sequential unordered {@code DoubleStreamEx}
 * @see DoubleStream#generate(DoubleSupplier)
 */
public static DoubleStreamEx generate(DoubleSupplier s) {
  return seq(DoubleStream.generate(s));
}

代码示例来源:origin: net.imglib2/imglib2-algorithm

/**
 *
 * Use the same weight for each dimension
 *
 * @param nDim
 *            number of dimensions
 * @param weight
 *            multiply squared difference between {@code x} and
 *            {@code xShift} with {@code weight}
 */
public EuclidianDistanceAnisotropic( final int nDim, final double weight )
{
  this( DoubleStream.generate( () -> weight ).limit( nDim ).toArray() );
}

代码示例来源:origin: kousen/java_8_recipes

@SuppressWarnings("SimplifyStreamApiCallChains")
  public static void main(String[] args) {
    boolean parallel = Stream.of(3, 1, 4, 1, 5, 9)
        .isParallel();
    System.out.println(parallel);

    parallel = IntStream.iterate(1, n -> n + 1)
        .isParallel();
    System.out.println(parallel);

    parallel = DoubleStream.generate(Math::random)
        .isParallel();
    System.out.println(parallel);

    parallel = Arrays.asList(3, 1, 4, 1, 5, 9).stream()
        .isParallel();
    System.out.println(parallel);

    parallel = Stream.of(3, 1, 4, 1, 5, 9)
        .parallel()
        .isParallel();
    System.out.println(parallel);

    parallel = Arrays.asList(3, 1, 4, 1, 5, 9).parallelStream()
        .isParallel();
    System.out.println(parallel);
  }
}

代码示例来源:origin: stanford-futuredata/macrobase

/**
 * Concatenate two DataFrames -- outlier and inlier -- into a single DataFrame, with a new
 * column that stores 1 if the row is originally from the outlier DF and 0 if it's from the
 * inlier DF
 *
 * @param outlierColName The name of the binary column that denotes outlier/inlier
 * @param outliersDf outlier DataFrame
 * @param inliersDf inlier DataFrame
 * @return new DataFrame that contains rows from both DataFrames, along with the extra binary
 * column
 */
private DataFrame concatOutliersAndInliers(final String outlierColName,
  final DataFrame outliersDf, final DataFrame inliersDf) {
  // Add column "outlier_col" to both outliers (all 1.0) and inliers (all 0.0)
  outliersDf.addColumn(outlierColName,
    DoubleStream.generate(() -> 1.0).limit(outliersDf.getNumRows()).toArray());
  inliersDf.addColumn(outlierColName,
    DoubleStream.generate(() -> 0.0).limit(inliersDf.getNumRows()).toArray());
  return DataFrame.unionAll(Lists.newArrayList(outliersDf, inliersDf));
}

代码示例来源:origin: com.netflix.kayenta/kayenta-atlas

List<Double> padding =
 DoubleStream
  .generate(() -> Double.NaN)
  .limit(offset)
  .boxed()

代码示例来源:origin: net.imglib2/imglib2-algorithm

final double[] w = weights.length == source.numDimensions() ? weights : DoubleStream.generate( () -> weights.length == 0 ? 1.0 : weights[ 0 ] ).limit( source.numDimensions() ).toArray();

代码示例来源:origin: BruceEckel/OnJava8-Examples

a8b = new Count.Double().array(SZ + 2);
show(a8b);
a8 = DoubleStream.generate(new Count.Pdouble())
 .limit(SZ + 1).toArray();
show(a8);

代码示例来源:origin: BruceEckel/OnJava8-Examples

a8b = new Rand.Double().array(SZ + 2);
show(a8b);
a8 = DoubleStream.generate(new Rand.Pdouble())
 .limit(SZ + 1).toArray();
show(a8);

代码示例来源:origin: imagej/imagej-ops

@Test
public void testAllForeground() {
  // SETUP
  final double scalingPow = DoubleStream.generate(() -> SCALING).limit(
    DIMENSIONS).reduce((i, j) -> i * j).orElse(0);
  final double[] expectedCounts = DoubleStream.iterate(1.0, i -> i *
    scalingPow).map(Math::log).limit(ITERATIONS).toArray();
  final Img<BitType> img = ArrayImgs.bits(TEST_DIMS);
  img.forEach(BitType::setOne);
  // EXECUTE
  final List<ValuePair<DoubleType, DoubleType>> points = ops.topology()
    .boxCount(img, MAX_SIZE, MIN_SIZE, SCALING);
  // VERIFY
  for (int i = 0; i < ITERATIONS; i++) {
    assertEquals(EXPECTED_SIZES[i], points.get(i).a.get(), 1e-12);
    assertEquals(expectedCounts[i], points.get(i).b.get(), 1e-12);
  }
}

代码示例来源:origin: net.imglib2/imglib2-algorithm

/**
 *
 * Switch for calling convenience method with pre-defined distances.
 *
 */
public static enum DISTANCE_TYPE
{
/**
 * Squared Euclidian distance using {@link EuclidianDistanceIsotropic} or
 * {@link EuclidianDistanceAnisotropic}.
 */
EUCLIDIAN,
/**
 * L1 distance using special case implementation.
 */
L1
}

相关文章