java.util.function.DoubleSupplier源码实例Demo

类java.util.function.DoubleSupplier源码实例Demo

下面列出了java.util.function.DoubleSupplier 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: presto   文件: TaskExecutor.java
public synchronized TaskHandle addTask(
        TaskId taskId,
        DoubleSupplier utilizationSupplier,
        int initialSplitConcurrency,
        Duration splitConcurrencyAdjustFrequency,
        OptionalInt maxDriversPerTask)
{
    requireNonNull(taskId, "taskId is null");
    requireNonNull(utilizationSupplier, "utilizationSupplier is null");
    checkArgument(maxDriversPerTask.isEmpty() || maxDriversPerTask.getAsInt() <= maximumNumberOfDriversPerTask,
            "maxDriversPerTask cannot be greater than the configured value");

    log.debug("Task scheduled " + taskId);

    TaskHandle taskHandle = new TaskHandle(taskId, waitingSplits, utilizationSupplier, initialSplitConcurrency, splitConcurrencyAdjustFrequency, maxDriversPerTask);

    tasks.add(taskHandle);
    return taskHandle;
}
 
源代码2 项目: presto   文件: TaskHandle.java
public TaskHandle(
        TaskId taskId,
        MultilevelSplitQueue splitQueue,
        DoubleSupplier utilizationSupplier,
        int initialSplitConcurrency,
        Duration splitConcurrencyAdjustFrequency,
        OptionalInt maxDriversPerTask)
{
    this.taskId = requireNonNull(taskId, "taskId is null");
    this.splitQueue = requireNonNull(splitQueue, "splitQueue is null");
    this.utilizationSupplier = requireNonNull(utilizationSupplier, "utilizationSupplier is null");
    this.maxDriversPerTask = requireNonNull(maxDriversPerTask, "maxDriversPerTask is null");
    this.concurrencyController = new SplitConcurrencyController(
            initialSplitConcurrency,
            requireNonNull(splitConcurrencyAdjustFrequency, "splitConcurrencyAdjustFrequency is null"));
}
 
源代码3 项目: JglTF   文件: ViewConfiguration.java
/**
 * Creates a new view configuration
 *  
 * @param viewportSupplier A supplier that supplies the viewport, 
 * as 4 float elements, [x, y, width, height]
 * @param aspectRatioSupplier An optional supplier for the aspect ratio. 
 * If this is <code>null</code>, then the aspect ratio of the 
 * camera will be used
 * @param externalViewMatrixSupplier The optional external supplier of
 * a view matrix.
 * @param externalProjectionMatrixSupplier The optional external supplier
 * of a projection matrix.
 */
ViewConfiguration(
    Supplier<float[]> viewportSupplier,
    DoubleSupplier aspectRatioSupplier,
    Supplier<float[]> externalViewMatrixSupplier, 
    Supplier<float[]> externalProjectionMatrixSupplier)
{
    this.viewportSupplier = Objects.requireNonNull(
        viewportSupplier, "The viewportSupplier may not be null");
    this.currentCameraModelSupplier = new SettableSupplier<CameraModel>();
    this.aspectRatioSupplier = aspectRatioSupplier;
    this.viewMatrixSupplier = 
        createViewMatrixSupplier(externalViewMatrixSupplier);
    this.projectionMatrixSupplier = 
        createProjectionMatrixSupplier(externalProjectionMatrixSupplier);
}
 
源代码4 项目: paintera   文件: Rotate.java
public Rotate(
		final DoubleSupplier speed,
		final AffineTransform3D globalTransform,
		final AffineTransform3D displayTransform,
		final AffineTransform3D globalToViewerTransform,
		final Consumer<AffineTransform3D> submitTransform,
		final Object lock)
{
	super();
	this.speed = speed;
	this.globalTransform = globalTransform;
	this.displayTransform = displayTransform;
	this.globalToViewerTransform = globalToViewerTransform;
	this.submitTransform = submitTransform;
	this.lock = lock;
}
 
源代码5 项目: paintera   文件: OpenDialogMenu.java
public static EventHandler<KeyEvent> keyPressedHandler(
		final PainteraGateway gateway,
		final Node target,
		Consumer<Exception> exceptionHandler,
		Predicate<KeyEvent> check,
		final String menuText,
		final PainteraBaseView viewer,
		final Supplier<String> projectDirectory,
		final DoubleSupplier x,
		final DoubleSupplier y)
{

	return event -> {
		if (check.test(event))
		{
			event.consume();
			OpenDialogMenu m = gateway.openDialogMenu();
			Optional<ContextMenu> cm = m.getContextMenu(menuText, viewer, projectDirectory, exceptionHandler);
			Bounds bounds = target.localToScreen(target.getBoundsInLocal());
			cm.ifPresent(menu -> menu.show(target, x.getAsDouble() + bounds.getMinX(), y.getAsDouble() + bounds.getMinY()));
		}
	};

}
 
源代码6 项目: commons-geometry   文件: VectorPerformance.java
/** Set up the instance for the benchmark.
 */
@Setup(Level.Iteration)
public void setup() {
    vectors = new ArrayList<>(size);

    final double[] values = new double[dimension];
    final DoubleSupplier doubleSupplier = createDoubleSupplier(getType(),
            RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP));

    for (int i = 0; i < size; ++i) {
        for (int j = 0; j < dimension; ++j) {
            values[j] = doubleSupplier.getAsDouble();
        }

        vectors.add(vectorFactory.apply(values));
    }
}
 
源代码7 项目: commons-geometry   文件: VectorPerformance.java
/** Create a supplier that produces doubles of the given type.
 * @param type type of doubles to produce
 * @param rng random provider
 * @return a supplier that produces doubles of the given type
 */
private DoubleSupplier createDoubleSupplier(final String type, final UniformRandomProvider rng) {
    switch (type) {
    case RANDOM:
        return () -> createRandomDouble(rng);
    case NORMALIZABLE:
        final ZigguratNormalizedGaussianSampler sampler = ZigguratNormalizedGaussianSampler.of(rng);
        return () -> {
            double n = sampler.sample();
            return n == 0 ? 0.1 : n; // do not return exactly zero
        };
    case EDGE:
        return () -> EDGE_NUMBERS[rng.nextInt(EDGE_NUMBERS.length)];
    default:
        throw new IllegalStateException("Invalid input type: " + type);
    }
}
 
源代码8 项目: commons-numbers   文件: SinCosPerformance.java
@Override
protected double[] createNumbers(SplittableRandom rng) {
    DoubleSupplier generator;
    if ("pi".equals(type)) {
        generator = () -> rng.nextDouble() * 2 * Math.PI - Math.PI;
    } else if ("pi/2".equals(type)) {
        generator = () -> rng.nextDouble() * Math.PI - Math.PI / 2;
    } else if ("random".equals(type)) {
        generator = () -> createRandomNumber(rng);
    } else if ("edge".equals(type)) {
        generator = () -> createEdgeNumber(rng);
    } else {
        throw new IllegalStateException("Unknown number type: " + type);
    }
    return DoubleStream.generate(generator).limit(getSize()).toArray();
}
 
源代码9 项目: besu   文件: PrometheusMetricsSystem.java
@Override
public void createGauge(
    final MetricCategory category,
    final String name,
    final String help,
    final DoubleSupplier valueSupplier) {
  final String metricName = convertToPrometheusName(category, name);
  if (isCategoryEnabled(category)) {
    final Collector collector = new CurrentValueCollector(metricName, help, valueSupplier);
    addCollectorUnchecked(category, collector);
  }
}
 
源代码10 项目: besu   文件: StubMetricsSystem.java
public double getGaugeValue(final String name) {
  final DoubleSupplier gauge = gauges.get(name);
  if (gauge == null) {
    throw new IllegalArgumentException("Unknown gauge: " + name);
  }
  return gauge.getAsDouble();
}
 
源代码11 项目: GregTech   文件: RecipeMap.java
public ModularUI.Builder createUITemplate(DoubleSupplier progressSupplier, IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids) {
    ModularUI.Builder builder = ModularUI.defaultBuilder();
    builder.widget(new ProgressWidget(progressSupplier, 77, 22, 20, 20, progressBarTexture, moveType));
    addInventorySlotGroup(builder, importItems, importFluids, false);
    addInventorySlotGroup(builder, exportItems, exportFluids, true);
    return builder;
}
 
源代码12 项目: GregTech   文件: RecipeMapGroupOutput.java
@Override
public Builder createUITemplate(DoubleSupplier progressSupplier, IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids) {
    ModularUI.Builder builder = ModularUI.defaultBuilder();
    builder.widget(new ProgressWidget(progressSupplier, 77, 22, 20, 20, progressBarTexture, moveType));
    addInventorySlotGroup(builder, importItems, importFluids, false);
    BooleanWrapper booleanWrapper = new BooleanWrapper();
    ServerWidgetGroup itemOutputGroup = createItemOutputWidgetGroup(exportItems, new ServerWidgetGroup(() -> !booleanWrapper.getCurrentMode()));
    ServerWidgetGroup fluidOutputGroup = createFluidOutputWidgetGroup(exportFluids, new ServerWidgetGroup(booleanWrapper::getCurrentMode));
    builder.widget(itemOutputGroup).widget(fluidOutputGroup);
    ToggleButtonWidget buttonWidget = new ToggleButtonWidget(176 - 7 - 20, 60, 20, 20,
        GuiTextures.BUTTON_SWITCH_VIEW, booleanWrapper::getCurrentMode, booleanWrapper::setCurrentMode)
        .setTooltipText("gregtech.gui.toggle_view");
    builder.widget(buttonWidget);
    return builder;
}
 
源代码13 项目: GregTech   文件: ProgressWidget.java
public ProgressWidget(DoubleSupplier progressSupplier, int x, int y, int width, int height, TextureArea fullImage, MoveType moveType) {
    super(new Position(x, y), new Size(width, height));
    this.progressSupplier = progressSupplier;
    this.emptyBarArea = fullImage.getSubArea(0.0, 0.0, 1.0, 0.5);
    this.filledBarArea = fullImage.getSubArea(0.0, 0.5, 1.0, 0.5);
    this.moveType = moveType;
}
 
源代码14 项目: GregTech   文件: MetaTileEntityLockedSafe.java
@Override
protected ModularUI createUI(EntityPlayer entityPlayer) {
    DoubleSupplier supplier = () -> 0.2 + (unlockProgress / (MAX_UNLOCK_PROGRESS * 1.0)) * 0.8;
    ModularUI.Builder builder = ModularUI.defaultBuilder()
        .widget(new ProgressWidget(supplier, 5, 5, 166, 74,
            GuiTextures.PROGRESS_BAR_UNLOCK,
            MoveType.VERTICAL_INVERTED))
        .bindPlayerInventory(entityPlayer.inventory);

    ServerWidgetGroup lockedGroup = new ServerWidgetGroup(() -> !isSafeUnlocked && unlockProgress < 0);
    lockedGroup.addWidget(new LabelWidget(5, 20, "gregtech.machine.locked_safe.malfunctioning"));
    lockedGroup.addWidget(new LabelWidget(5, 30, "gregtech.machine.locked_safe.requirements"));

    lockedGroup.addWidget(new SlotWidget(unlockInventory, 0, 70, 40, false, true).setBackgroundTexture(GuiTextures.SLOT));
    lockedGroup.addWidget(new SlotWidget(unlockInventory, 1, 70 + 18, 40, false, true).setBackgroundTexture(GuiTextures.SLOT));

    lockedGroup.addWidget(new SlotWidget(unlockComponents, 0, 70, 58, false, false));
    lockedGroup.addWidget(new SlotWidget(unlockComponents, 1, 70 + 18, 58, false, false));

    ServerWidgetGroup unlockedGroup = new ServerWidgetGroup(() -> isSafeUnlocked);
    for (int row = 0; row < 3; row++) {
        for (int col = 0; col < 9; col++) {
            unlockedGroup.addWidget(new SlotWidget(safeLootInventory, col + row * 9,
                8 + col * 18, 15 + row * 18, true, false));
        }
    }

    return builder.widget(unlockedGroup)
        .widget(lockedGroup)
        .build(getHolder(), entityPlayer);
}
 
源代码15 项目: paintera   文件: TranslateAlongNormal.java
public TranslateAlongNormal(
		final DoubleSupplier translationSpeed,
		final GlobalTransformManager manager,
		final AffineTransform3D worldToSharedViewerSpace,
		final Object lock)
{
	this.translationSpeed = translationSpeed;
	this.manager = manager;
	this.worldToSharedViewerSpace = worldToSharedViewerSpace;
	this.lock = lock;

	manager.addListener(global::set);
}
 
源代码16 项目: paintera   文件: Zoom.java
public Zoom(
		final DoubleSupplier speed,
		final GlobalTransformManager manager,
		final AffineTransform3D concatenated,
		final Object lock)
{
	this.speed = speed;
	this.manager = manager;
	this.concatenated = concatenated;
	this.lock = lock;

	this.manager.addListener(global::set);
}
 
源代码17 项目: teku   文件: StubMetricsSystem.java
@Override
public void createGauge(
    final MetricCategory category,
    final String name,
    final String help,
    final DoubleSupplier valueSupplier) {
  final StubGauge guage = new StubGauge(category, name, help, valueSupplier);
  final Map<String, StubGauge> gaugesInCategory =
      gauges.computeIfAbsent(category, key -> new ConcurrentHashMap<>());

  if (gaugesInCategory.putIfAbsent(name, guage) != null) {
    throw new IllegalArgumentException("Attempting to create two gauges with the same name");
  }
}
 
源代码18 项目: teku   文件: StubGauge.java
protected StubGauge(
    final MetricCategory category,
    final String name,
    final String help,
    final DoubleSupplier supplier) {
  super(category, name, help);
  this.supplier = supplier;
}
 
源代码19 项目: commons-geometry   文件: SphereTest.java
@Test
public void testToTree_randomSpheres() {
    // arrange
    UniformRandomProvider rand = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP, 1L);
    DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-10);
    double min = 1e-1;
    double max = 1e2;

    DoubleSupplier randDouble = () -> (rand.nextDouble() * (max - min)) + min;

    int count = 10;
    for (int i = 0; i < count; ++i) {
        Vector3D center = Vector3D.of(
                randDouble.getAsDouble(),
                randDouble.getAsDouble(),
                randDouble.getAsDouble());

        double radius = randDouble.getAsDouble();
        Sphere sphere = Sphere.from(center, radius, precision);

        for (int s = 0; s < 7; ++s) {
            // act
            RegionBSPTree3D tree = sphere.toTree(s);

            // assert
            Assert.assertEquals((int)(8 * Math.pow(4, s)), tree.getBoundaries().size());
            Assert.assertTrue(tree.isFinite());
            Assert.assertFalse(tree.isEmpty());
            Assert.assertTrue(tree.getSize() < sphere.getSize());
        }
    }
}
 
源代码20 项目: o2oa   文件: CalculateEntryTools.java
private static Double average(Table table, CalculateEntry calculateEntry) throws Exception {
	DoubleSupplier ds = () -> {
		return 0d;
	};
	Double result = table.stream().mapToDouble(row -> row.getAsDouble(calculateEntry.getColumn())).average()
			.orElseGet(ds);
	return result;
}
 
源代码21 项目: o2oa   文件: CalculateEntry.java
protected Double average(Table table) throws Exception {
	DoubleSupplier ds = () -> {
		return 0d;
	};
	Double result = table.stream().mapToDouble(row -> row.getAsDouble(this.column)).average().orElseGet(ds);
	return result;
}
 
源代码22 项目: micrometer   文件: PostgreSQLDatabaseMetrics.java
/**
 * Function that makes sure functional counter values survive pg_stat_reset calls.
 */
Double resettableFunctionalCounter(String functionalCounterKey, DoubleSupplier function) {
    Double result = function.getAsDouble();
    Double previousResult = previousValueCacheMap.getOrDefault(functionalCounterKey, 0D);
    Double beforeResetValue = beforeResetValuesCacheMap.getOrDefault(functionalCounterKey, 0D);
    Double correctedValue = result + beforeResetValue;

    if (correctedValue < previousResult) {
        beforeResetValuesCacheMap.put(functionalCounterKey, previousResult);
        correctedValue = previousResult + result;
    }
    previousValueCacheMap.put(functionalCounterKey, correctedValue);
    return correctedValue;
}
 
源代码23 项目: besu   文件: CurrentValueCollector.java
public CurrentValueCollector(
    final String metricName, final String help, final DoubleSupplier valueSupplier) {
  this.metricName = metricName;
  this.help = help;
  this.valueSupplier = valueSupplier;
}
 
源代码24 项目: besu   文件: NoOpMetricsSystem.java
@Override
public void createGauge(
    final MetricCategory category,
    final String name,
    final String help,
    final DoubleSupplier valueSupplier) {}
 
源代码25 项目: openjdk-8   文件: StreamSpliterators.java
OfDouble(long size, DoubleSupplier s) {
    super(size);
    this.s = s;
}
 
OfDouble(long size, DoubleSupplier s) {
    super(size);
    this.s = s;
}
 
源代码27 项目: TencentKona-8   文件: StreamSpliterators.java
OfDouble(long size, DoubleSupplier s) {
    super(size);
    this.s = s;
}
 
源代码28 项目: jdk8u_jdk   文件: StreamSpliterators.java
OfDouble(long size, DoubleSupplier s) {
    super(size);
    this.s = s;
}
 
源代码29 项目: GregTech   文件: ModularUI.java
public Builder progressBar(DoubleSupplier progressSupplier, int x, int y, int width, int height, TextureArea texture, MoveType moveType) {
    return widget(new ProgressWidget(progressSupplier, x, y, width, height, texture, moveType));
}
 
源代码30 项目: jdk8u60   文件: StreamSpliterators.java
OfDouble(long size, DoubleSupplier s) {
    super(size);
    this.s = s;
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法