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


Java DoubleAccumulator.accumulate方法代码示例

本文整理汇总了Java中java.util.concurrent.atomic.DoubleAccumulator.accumulate方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleAccumulator.accumulate方法的具体用法?Java DoubleAccumulator.accumulate怎么用?Java DoubleAccumulator.accumulate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.atomic.DoubleAccumulator的用法示例。


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

示例1: testDoubleAccumulator

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");

    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:Serial.java

示例2: testAccumulateAndGet

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * accumulate accumulates given value to current, and get returns current value
 */
public void testAccumulateAndGet() {
    DoubleAccumulator acc = new DoubleAccumulator(Double::max, 0.0);
    acc.accumulate(2.0);
    assertEquals(2.0, acc.get());
    acc.accumulate(-4.0);
    assertEquals(2.0, acc.get());
    acc.accumulate(4.0);
    assertEquals(4.0, acc.get());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:DoubleAccumulatorTest.java

示例3: testReset

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * reset() causes subsequent get() to return zero
 */
public void testReset() {
    DoubleAccumulator acc = new DoubleAccumulator(Double::max, 0.0);
    acc.accumulate(2.0);
    assertEquals(2.0, acc.get());
    acc.reset();
    assertEquals(0.0, acc.get());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:DoubleAccumulatorTest.java

示例4: testGetThenReset

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * getThenReset() returns current value; subsequent get() returns zero
 */
public void testGetThenReset() {
    DoubleAccumulator acc = new DoubleAccumulator(Double::max, 0.0);
    acc.accumulate(2.0);
    assertEquals(2.0, acc.get());
    assertEquals(2.0, acc.getThenReset());
    assertEquals(0.0, acc.get());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:DoubleAccumulatorTest.java

示例5: testToString

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * toString returns current value.
 */
public void testToString() {
    DoubleAccumulator acc = new DoubleAccumulator(Double::max, 0.0);
    assertEquals("0.0", acc.toString());
    acc.accumulate(1.0);
    assertEquals(Double.toString(1.0), acc.toString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:DoubleAccumulatorTest.java

示例6: testIntValue

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * intValue returns current value.
 */
public void testIntValue() {
    DoubleAccumulator acc = new DoubleAccumulator(Double::max, 0.0);
    assertEquals(0, acc.intValue());
    acc.accumulate(1.0);
    assertEquals(1, acc.intValue());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:DoubleAccumulatorTest.java

示例7: testLongValue

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * longValue returns current value.
 */
public void testLongValue() {
    DoubleAccumulator acc = new DoubleAccumulator(Double::max, 0.0);
    assertEquals(0, acc.longValue());
    acc.accumulate(1.0);
    assertEquals(1, acc.longValue());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:DoubleAccumulatorTest.java

示例8: testFloatValue

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * floatValue returns current value.
 */
public void testFloatValue() {
    DoubleAccumulator acc = new DoubleAccumulator(Double::max, 0.0);
    assertEquals(0.0f, acc.floatValue());
    acc.accumulate(1.0);
    assertEquals(1.0f, acc.floatValue());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:DoubleAccumulatorTest.java

示例9: testDoubleValue

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * doubleValue returns current value.
 */
public void testDoubleValue() {
    DoubleAccumulator acc = new DoubleAccumulator(Double::max, 0.0);
    assertEquals(0.0, acc.doubleValue());
    acc.accumulate(1.0);
    assertEquals(1.0, acc.doubleValue());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:DoubleAccumulatorTest.java

示例10: testAccumulateAndGet

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * accumulate accumulates given value to current, and get returns current value
 */
public void testAccumulateAndGet() {
    DoubleAccumulator ai = new DoubleAccumulator(Double::max, 0.0);
    ai.accumulate(2.0);
    assertEquals(2.0, ai.get());
    ai.accumulate(-4.0);
    assertEquals(2.0, ai.get());
    ai.accumulate(4.0);
    assertEquals(4.0, ai.get());
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:13,代码来源:DoubleAccumulatorTest.java

示例11: testReset

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * reset() causes subsequent get() to return zero
 */
public void testReset() {
    DoubleAccumulator ai = new DoubleAccumulator(Double::max, 0.0);
    ai.accumulate(2.0);
    assertEquals(2.0, ai.get());
    ai.reset();
    assertEquals(0.0, ai.get());
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:11,代码来源:DoubleAccumulatorTest.java

示例12: testGetThenReset

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * getThenReset() returns current value; subsequent get() returns zero
 */
public void testGetThenReset() {
    DoubleAccumulator ai = new DoubleAccumulator(Double::max, 0.0);
    ai.accumulate(2.0);
    assertEquals(2.0, ai.get());
    assertEquals(2.0, ai.getThenReset());
    assertEquals(0.0, ai.get());
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:11,代码来源:DoubleAccumulatorTest.java

示例13: testToString

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * toString returns current value.
 */
public void testToString() {
    DoubleAccumulator ai = new DoubleAccumulator(Double::max, 0.0);
    assertEquals("0.0", ai.toString());
    ai.accumulate(1.0);
    assertEquals(Double.toString(1.0), ai.toString());
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:10,代码来源:DoubleAccumulatorTest.java

示例14: testIntValue

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * intValue returns current value.
 */
public void testIntValue() {
    DoubleAccumulator ai = new DoubleAccumulator(Double::max, 0.0);
    assertEquals(0, ai.intValue());
    ai.accumulate(1.0);
    assertEquals(1, ai.intValue());
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:10,代码来源:DoubleAccumulatorTest.java

示例15: testLongValue

import java.util.concurrent.atomic.DoubleAccumulator; //导入方法依赖的package包/类
/**
 * longValue returns current value.
 */
public void testLongValue() {
    DoubleAccumulator ai = new DoubleAccumulator(Double::max, 0.0);
    assertEquals(0, ai.longValue());
    ai.accumulate(1.0);
    assertEquals(1, ai.longValue());
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:10,代码来源:DoubleAccumulatorTest.java


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