当前位置: 首页>>代码示例>>Java>>正文


Java ToDoubleBiFunction类代码示例

本文整理汇总了Java中java.util.function.ToDoubleBiFunction的典型用法代码示例。如果您正苦于以下问题:Java ToDoubleBiFunction类的具体用法?Java ToDoubleBiFunction怎么用?Java ToDoubleBiFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ToDoubleBiFunction类属于java.util.function包,在下文中一共展示了ToDoubleBiFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NestableLoadProfileEstimator

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
/**
 * Creates an new instance.
 *
 * @param cpuLoadEstimator             estimates CPU load in terms of cycles
 * @param ramLoadEstimator             estimates RAM load in terms of bytes
 * @param diskLoadEstimator            estimates disk accesses in terms of bytes
 * @param networkLoadEstimator         estimates network in terms of bytes
 * @param resourceUtilizationEstimator degree to which the load profile can utilize available resources
 * @param overheadMillis               overhead that this load profile incurs
 * @param configurationKey             from that this instances was perceived
 */
public NestableLoadProfileEstimator(LoadEstimator cpuLoadEstimator,
                                    LoadEstimator ramLoadEstimator,
                                    LoadEstimator diskLoadEstimator,
                                    LoadEstimator networkLoadEstimator,
                                    ToDoubleBiFunction<long[], long[]> resourceUtilizationEstimator,
                                    long overheadMillis,
                                    String configurationKey) {
    this.cpuLoadEstimator = cpuLoadEstimator;
    this.ramLoadEstimator = ramLoadEstimator;
    this.diskLoadEstimator = diskLoadEstimator;
    this.networkLoadEstimator = networkLoadEstimator;
    this.resourceUtilizationEstimator = resourceUtilizationEstimator;
    this.overheadMillis = overheadMillis;
    this.configurationKey = configurationKey;
}
 
开发者ID:daqcri,项目名称:rheem,代码行数:27,代码来源:NestableLoadProfileEstimator.java

示例2: shouldMemoizeBiFunction

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
/**
*
*/
@Test
public void shouldMemoizeBiFunction() {
    // given
    final ToDoubleBiFunction<String, String> function = (first, second) -> 123;
    final BiFunction<String, String, String> keyfunction = hashCodeKeyFunction();
    try (final Cache<String, Double> cache = JCacheMemoize.createCache(ToDoubleBiFunction.class)) {
        // when
        final JCacheBasedToDoubleBiFunctionMemoizer<String, String, String> loader = new JCacheBasedToDoubleBiFunctionMemoizer<>(
                cache, keyfunction, function);

        // then
        Assert.assertEquals("Memoized value does not match expectation", 123D,
                loader.applyAsDouble("first", "second"), 0.0D);
    }
}
 
开发者ID:sebhoss,项目名称:memoization.java,代码行数:19,代码来源:JCacheBasedToDoubleBiFunctionMemoizerTest.java

示例3: shouldRequireNonNullCache

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
/**
 *
 */
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullCache() {
    // given
    final ConcurrentMap<String, Double> cache = null;
    final BiFunction<String, String, String> keyFunction = (a, b) -> "key";
    final ToDoubleBiFunction<String, String> biFunction = (a, b) -> 123.456D;

    // when
    thrown.expect(NullPointerException.class);
    thrown.expectMessage("Provide an empty map instead of NULL.");

    // then
    new ConcurrentMapBasedToDoubleBiFunctionMemoizer<>(cache, keyFunction, biFunction);
}
 
开发者ID:sebhoss,项目名称:memoization.java,代码行数:19,代码来源:ConcurrentMapBasedToDoubleBiFunctionMemoizerTest.java

示例4: shouldRequireNonNullKeyBiFunction

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
/**
 *
 */
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullKeyBiFunction() {
    // given
    final ConcurrentMap<String, Double> cache = new ConcurrentHashMap<>();
    final BiFunction<String, String, String> keyFunction = null;
    final ToDoubleBiFunction<String, String> biFunction = (a, b) -> 123.456D;

    // when
    thrown.expect(NullPointerException.class);
    thrown.expectMessage("Provide a key function, might just be 'MemoizationDefaults.hashCodeKeyFunction()'.");

    // then
    new ConcurrentMapBasedToDoubleBiFunctionMemoizer<>(cache, keyFunction, biFunction);
}
 
开发者ID:sebhoss,项目名称:memoization.java,代码行数:19,代码来源:ConcurrentMapBasedToDoubleBiFunctionMemoizerTest.java

示例5: shouldRequireNonNullBiFunction

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
/**
 *
 */
@Test
@SuppressWarnings(CompilerWarnings.UNUSED)
public void shouldRequireNonNullBiFunction() {
    // given
    final ConcurrentMap<String, Double> cache = new ConcurrentHashMap<>();
    final BiFunction<String, String, String> keyFunction = (a, b) -> "key";
    final ToDoubleBiFunction<String, String> biFunction = null;

    // when
    thrown.expect(NullPointerException.class);
    thrown.expectMessage(
            "Cannot memoize a NULL ToDoubleBiFunction - provide an actual ToDoubleBiFunction to fix this.");

    // then
    new ConcurrentMapBasedToDoubleBiFunctionMemoizer<>(cache, keyFunction, biFunction);
}
 
开发者ID:sebhoss,项目名称:memoization.java,代码行数:20,代码来源:ConcurrentMapBasedToDoubleBiFunctionMemoizerTest.java

示例6: shouldUseSetCacheKeyAndValue

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
/**
*
*/
@Test
public void shouldUseSetCacheKeyAndValue() {
    // given
    final ConcurrentMap<String, Double> cache = new ConcurrentHashMap<>();
    final BiFunction<String, String, String> keyFunction = (a, b) -> "key";
    final ToDoubleBiFunction<String, String> biFunction = (a, b) -> 123.456D;

    // when
    final ConcurrentMapBasedToDoubleBiFunctionMemoizer<String, String, String> memoizer = new ConcurrentMapBasedToDoubleBiFunctionMemoizer<>(
            cache, keyFunction, biFunction);

    // then
    memoizer.applyAsDouble("123.456", "789.123");
    Assert.assertFalse("Cache is still empty after memoization", memoizer.viewCacheForTest().isEmpty());
    Assert.assertEquals("Memoization key does not match expectations", "key",
            memoizer.viewCacheForTest().keySet().iterator().next());
    Assert.assertEquals("Memoization value does not match expectations", 123.456D,
            memoizer.viewCacheForTest().values().iterator().next().doubleValue(), 0.0D);
}
 
开发者ID:sebhoss,项目名称:memoization.java,代码行数:23,代码来源:ConcurrentMapBasedToDoubleBiFunctionMemoizerTest.java

示例7: shouldUseCallWrappedBiFunction

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNCHECKED)
public void shouldUseCallWrappedBiFunction() {
    // given
    final ConcurrentMap<String, Double> cache = new ConcurrentHashMap<>();
    final BiFunction<String, String, String> keyFunction = (a, b) -> "key";
    final ToDoubleBiFunction<String, String> biFunction = Mockito.mock(ToDoubleBiFunction.class);

    // when
    final ConcurrentMapBasedToDoubleBiFunctionMemoizer<String, String, String> memoizer = new ConcurrentMapBasedToDoubleBiFunctionMemoizer<>(
            cache, keyFunction, biFunction);

    // then
    memoizer.applyAsDouble("123.456", "789.123");
    Mockito.verify(biFunction).applyAsDouble("123.456", "789.123");
}
 
开发者ID:sebhoss,项目名称:memoization.java,代码行数:20,代码来源:ConcurrentMapBasedToDoubleBiFunctionMemoizerTest.java

示例8: integrate2d

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
public static double integrate2d(final ToDoubleBiFunction<Double, Double> getIntegrand,
                          final double xLowerBound, final double xUpperBound, final int xNumPoints,
                          final double yLowerBound, final double yUpperBound, final int yNumPoints){
    final GaussIntegrator xIntegrator = integratorFactory.legendre(xNumPoints, xLowerBound, xUpperBound);
    final GaussIntegrator yIntegrator = integratorFactory.legendre(yNumPoints, yLowerBound, yUpperBound);

    final double[] xIntegrationWeights = new IndexRange(0, xNumPoints).mapToDouble(xIntegrator::getWeight);
    final double[] xAbscissas = new IndexRange(0, xNumPoints).mapToDouble(xIntegrator::getPoint);

    final double[] yIntegrationWeights = new IndexRange(0, yNumPoints).mapToDouble(yIntegrator::getWeight);
    final double[] yAbscissas = new IndexRange(0, yNumPoints).mapToDouble(yIntegrator::getPoint);

    double integral = 0;
    for (int i = 0; i < xNumPoints; i++) {
        final double x = xAbscissas[i];
        for (int j = 0; j < yNumPoints; j++) {
            final double y = yAbscissas[j];
            final double integrand = getIntegrand.applyAsDouble(x, y);
            integral += xIntegrationWeights[i] * yIntegrationWeights[j] * integrand;
        }
    }

    return integral;
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:25,代码来源:IntegrationUtils.java

示例9: sum

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
@Override
public double sum(ToDoubleBiFunction<? super Integer, ? super T> mapper) {
    ToDoubleFunction<T> function;
    if (!isParallel()) {
        // use fast sequential counting
        function = new ToDoubleFunction<T>() {
            int i = 0;
            @Override
            public double applyAsDouble(T t) {
                return mapper.applyAsDouble(i++, t);
            }
        };
    }
    else {
        // retrieve each index individually
        function = new ToDoubleFunction<T>() {
            List<T> list = stream().collect(Collectors.toList());
            @Override
            public double applyAsDouble(T t) {
                return mapper.applyAsDouble(list.indexOf(t), t);
            }
        };
    }
    return stream().collect(Collectors.summingDouble(function));
}
 
开发者ID:codebulb,项目名称:LambdaOmega,代码行数:26,代码来源:L.java

示例10: testCheckedToDoubleBiFunction

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
@Test
public void testCheckedToDoubleBiFunction() {
    final CheckedToDoubleBiFunction<Object, Object> toDoubleBiFunction = (t, u) -> {
        throw new Exception(t + ":" + u);
    };

    ToDoubleBiFunction<Object, Object> f1 = Unchecked.toDoubleBiFunction(toDoubleBiFunction);
    ToDoubleBiFunction<Object, Object> f2 = CheckedToDoubleBiFunction.unchecked(toDoubleBiFunction);
    ToDoubleBiFunction<Object, Object> f3 = Sneaky.toDoubleBiFunction(toDoubleBiFunction);
    ToDoubleBiFunction<Object, Object> f4 = CheckedToDoubleBiFunction.sneaky(toDoubleBiFunction);

    assertToDoubleBiFunction(f1, UncheckedException.class);
    assertToDoubleBiFunction(f2, UncheckedException.class);
    assertToDoubleBiFunction(f3, Exception.class);
    assertToDoubleBiFunction(f4, Exception.class);
}
 
开发者ID:jOOQ,项目名称:jOOL,代码行数:17,代码来源:CheckedBiFunctionTest.java

示例11: super

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
MapReduceMappingsToDoubleTask
    (BulkTask<K,V,?> p, int b, int i, int f, Node<K,V>[] t,
     MapReduceMappingsToDoubleTask<K,V> nextRight,
     ToDoubleBiFunction<? super K, ? super V> transformer,
     double basis,
     DoubleBinaryOperator reducer) {
    super(p, b, i, f, t); this.nextRight = nextRight;
    this.transformer = transformer;
    this.basis = basis; this.reducer = reducer;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:ConcurrentHashMap.java

示例12: compute

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
public final void compute() {
    final ToDoubleBiFunction<? super K, ? super V> transformer;
    final DoubleBinaryOperator reducer;
    if ((transformer = this.transformer) != null &&
        (reducer = this.reducer) != null) {
        double r = this.basis;
        for (int i = baseIndex, f, h; batch > 0 &&
                 (h = ((f = baseLimit) + i) >>> 1) > i;) {
            addToPendingCount(1);
            (rights = new MapReduceMappingsToDoubleTask<K,V>
             (this, batch >>>= 1, baseLimit = h, f, tab,
              rights, transformer, r, reducer)).fork();
        }
        for (Node<K,V> p; (p = advance()) != null; )
            r = reducer.applyAsDouble(r, transformer.applyAsDouble(p.key, p.val));
        result = r;
        CountedCompleter<?> c;
        for (c = firstComplete(); c != null; c = c.nextComplete()) {
            @SuppressWarnings("unchecked")
            MapReduceMappingsToDoubleTask<K,V>
                t = (MapReduceMappingsToDoubleTask<K,V>)c,
                s = t.rights;
            while (s != null) {
                t.result = reducer.applyAsDouble(t.result, s.result);
                s = t.rights = s.nextRight;
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:ConcurrentHashMap.java

示例13: SimpleViterbi

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
/**
 * @param scorer      打分算法
 * @param mapFunction 一个Node,获得tag-score健值对
 * @param consumer    set选定的标签
 */
public SimpleViterbi(
        ToDoubleBiFunction<Map.Entry<TagType, Integer>,
                Map.Entry<TagType, Integer>> scorer,
        Function<ObjType, Map<TagType, Integer>> mapFunction,
        BiConsumer<ObjType, TagType> consumer
) {
    this.consumer = consumer;
    this.scorer = scorer;
    this.mapFunction = mapFunction;
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:16,代码来源:SimpleViterbi.java

示例14: compute

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
@Override
public final void compute() {
    final ToDoubleBiFunction<? super K, ? super V> transformer;
    final DoubleBinaryOperator reducer;
    if ((transformer = this.transformer) != null &&
        (reducer = this.reducer) != null) {
        double r = this.basis;
        for (int i = this.baseIndex, f, h; this.batch > 0 &&
                 (h = ((f = this.baseLimit) + i) >>> 1) > i;) {
            this.addToPendingCount(1);
            (this.rights = new MapReduceMappingsToDoubleTask<K,V>
             (this, this.batch >>>= 1, this.baseLimit = h, f, this.tab,
              this.rights, transformer, r, reducer)).fork();
        }
        for (Node<K,V> p; (p = this.advance()) != null; ) {
            r = reducer.applyAsDouble(r, transformer.applyAsDouble(p.key, p.val));
        }
        this.result = r;
        CountedCompleter<?> c;
        for (c = this.firstComplete(); c != null; c = c.nextComplete()) {
            @SuppressWarnings("unchecked")
            MapReduceMappingsToDoubleTask<K,V>
                t = (MapReduceMappingsToDoubleTask<K,V>)c,
                s = t.rights;
            while (s != null) {
                t.result = reducer.applyAsDouble(t.result, s.result);
                s = t.rights = s.nextRight;
            }
        }
    }
}
 
开发者ID:TestingResearchIllinois,项目名称:NonDex,代码行数:32,代码来源:ConcurrentHashMap.java

示例15: MapReduceMappingsToDoubleTask

import java.util.function.ToDoubleBiFunction; //导入依赖的package包/类
MapReduceMappingsToDoubleTask(final BulkTask<K, V, ?> p, final int b, final int i, final int f, final Node<K, V>[] t, final MapReduceMappingsToDoubleTask<K, V> nextRight, final ToDoubleBiFunction<? super K, ? super V> transformer, final double basis, final DoubleBinaryOperator reducer)
{
    super(p, b, i, f, t);
    this.nextRight = nextRight;
    this.transformer = transformer;
    this.basis = basis;
    this.reducer = reducer;
}
 
开发者ID:Diorite,项目名称:Diorite-old,代码行数:9,代码来源:ConcurrentIdentityHashMap.java


注:本文中的java.util.function.ToDoubleBiFunction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。