List of usage examples for java.util Arrays setAll
public static void setAll(double[] array, IntToDoubleFunction generator)
From source file:io.druid.query.aggregation.datasketches.tuple.ArrayOfDoublesSketchToMeansPostAggregator.java
@Override public double[] compute(final Map<String, Object> combinedAggregators) { final ArrayOfDoublesSketch sketch = (ArrayOfDoublesSketch) getField().compute(combinedAggregators); final SummaryStatistics[] stats = new SummaryStatistics[sketch.getNumValues()]; Arrays.setAll(stats, i -> new SummaryStatistics()); final ArrayOfDoublesSketchIterator it = sketch.iterator(); while (it.next()) { final double[] values = it.getValues(); for (int i = 0; i < values.length; i++) { stats[i].addValue(values[i]); }/*w w w .ja va 2 s. c o m*/ } final double[] means = new double[sketch.getNumValues()]; Arrays.setAll(means, i -> stats[i].getMean()); return means; }
From source file:io.druid.query.aggregation.datasketches.tuple.ArrayOfDoublesSketchToVariancesPostAggregator.java
@Override public double[] compute(final Map<String, Object> combinedAggregators) { final ArrayOfDoublesSketch sketch = (ArrayOfDoublesSketch) getField().compute(combinedAggregators); final SummaryStatistics[] stats = new SummaryStatistics[sketch.getNumValues()]; Arrays.setAll(stats, i -> new SummaryStatistics()); final ArrayOfDoublesSketchIterator it = sketch.iterator(); while (it.next()) { final double[] values = it.getValues(); for (int i = 0; i < values.length; i++) { stats[i].addValue(values[i]); }/*from w w w . j ava 2 s .c o m*/ } final double[] variances = new double[sketch.getNumValues()]; Arrays.setAll(variances, i -> stats[i].getVariance()); return variances; }
From source file:io.druid.query.aggregation.datasketches.tuple.ArrayOfDoublesSketchTTestPostAggregator.java
private static SummaryStatistics[] getStats(final ArrayOfDoublesSketch sketch) { final SummaryStatistics[] stats = new SummaryStatistics[sketch.getNumValues()]; Arrays.setAll(stats, i -> new SummaryStatistics()); final ArrayOfDoublesSketchIterator it = sketch.iterator(); while (it.next()) { final double[] values = it.getValues(); for (int i = 0; i < values.length; i++) { stats[i].addValue(values[i]); }/*from w ww.j ava2s .c o m*/ } return stats; }
From source file:com.github.benmanes.caffeine.cache.Stresser.java
public Stresser() { ThreadFactory threadFactory = new ThreadFactoryBuilder().setPriority(Thread.MAX_PRIORITY).setDaemon(true) .build();//from ww w. j a v a2 s .co m Executors.newSingleThreadScheduledExecutor(threadFactory).scheduleAtFixedRate(this::status, STATUS_INTERVAL, STATUS_INTERVAL, SECONDS); cache = Caffeine.newBuilder().maximumSize(operation.maxEntries).recordStats().build(key -> key); local = (BoundedLocalCache<Integer, Integer>) cache.asMap(); ints = new Integer[TOTAL_KEYS]; Arrays.setAll(ints, key -> { cache.put(key, key); return key; }); cache.cleanUp(); stopwatch = Stopwatch.createStarted(); status(); }
From source file:org.hawkular.rx.commands.hawkular.CreateUrlCommand.java
protected String getDomainSorterUrl(String url) { //http://git.io/vRIHB try {//from w w w . jav a 2s. c o m URL urlInstance = new URL(url); String[] levels = urlInstance.getHost().split("."); if (levels != null && levels.length > 1) { String[] levelsSorted = new String[levels.length]; //"a.b.redhat.com" will produce "redhat.com.a.b" Arrays.setAll(levelsSorted, i -> { switch (i) { case 0: case 1: String level = levels[levels.length - 1 - i]; //replace all the www's with a space so that they sort before any other name return "www".equals(level) ? " " : level; default: level = levels[i]; return "www".equals(level) ? " " : level; } }); return StringUtils.join(levelsSorted, "."); } return url; } catch (MalformedURLException e) { return url; } }
From source file:com.simiacryptus.mindseye.lang.Tensor.java
/** * Fill tensor./* w w w . j a v a 2s . c om*/ * * @param f the f * @return the tensor */ @Nonnull public Tensor set(@Nonnull final DoubleSupplier f) { Arrays.setAll(getData(), i -> f.getAsDouble()); return this; }
From source file:org.blockedit.core.world.Section.java
private ArrayList<Byte> getArrayList(byte[] original) { Byte[] byteArray = new Byte[original.length]; Arrays.setAll(byteArray, n -> original[n]); return new ArrayList<>(Arrays.asList(byteArray)); }
From source file:org.mpetnuch.gauss.linearalgebra.blas3.JBlasLevel3Test.java
private static double[][] generateData(int m, int n) { final Random randomStream = new Random((long) m * n); final double[][] data = new double[m][]; Arrays.setAll(data, value -> randomStream.doubles(n).toArray()); return data;/*from ww w . ja va2 s. co m*/ }