本文整理汇总了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");
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}