Home
last modified time | relevance | path

Searched refs:sum (Results 1 – 25 of 83) sorted by relevance

1234

/libcore/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/
DLongPrimitiveOpsTests.java42 long sum = LongStream.range(1, 10).filter(i -> i % 2 == 0).sum(); in testSum() local
43 assertEquals(sum, 20); in testSum()
47 long sum = LongStream.range(1, 10).filter(i -> i % 2 == 0).map(i -> i * 2).sum(); in testMap() local
48 assertEquals(sum, 40); in testMap()
52 long sum = LongStream.range(1, 10).parallel().filter(i -> i % 2 == 0).sum(); in testParSum() local
53 assertEquals(sum, 20); in testParSum()
59 …long sum = LongStream.range(1, 10).filter(i -> i % 2 == 0).peek(i -> { teeSum[0] = teeSum[0] + i; … in testTee() local
60 assertEquals(teeSum[0], sum); in testTee()
65 long[] sum = new long[1]; in testForEach() local
66 LongStream.range(1, 10).filter(i -> i % 2 == 0).forEach(i -> { sum[0] = sum[0] + i; }); in testForEach()
[all …]
DIntPrimitiveOpsTests.java42 long sum = IntStream.range(1, 10).filter(i -> i % 2 == 0).sum(); in testSum() local
43 assertEquals(sum, 20); in testSum()
47 long sum = IntStream.range(1, 10).filter(i -> i % 2 == 0).map(i -> i * 2).sum(); in testMap() local
48 assertEquals(sum, 40); in testMap()
52 long sum = IntStream.range(1, 10).parallel().filter(i -> i % 2 == 0).sum(); in testParSum() local
53 assertEquals(sum, 20); in testParSum()
59 …long sum = IntStream.range(1, 10).filter(i -> i % 2 == 0).peek(i -> { teeSum[0] = teeSum[0] + i; }… in testTee() local
60 assertEquals(teeSum[0], sum); in testTee()
65 int[] sum = new int[1]; in testForEach() local
66 IntStream.range(1, 10).filter(i -> i % 2 == 0).forEach(i -> { sum[0] = sum[0] + i; }); in testForEach()
[all …]
DPrimitiveSumTest.java45 exerciseTerminalOps(data, s -> s.sum()); in testOps()
48 terminal(s -> (long) s.sum()). in testOps()
55 exerciseTerminalOps(data, s -> s.sum()); in testOps()
58 terminal(s -> s.sum()). in testOps()
69 exerciseTerminalOps(data, s -> s.sum()); in testOps()
72 terminal(s -> s.sum()). in testOps()
DTabulatorsTest.java289 assertCollect(data, Collectors.reducing(0, Integer::sum),
290 s -> s.reduce(0, Integer::sum));
296 assertCollect(data, Collectors.reducing(Integer::sum),
297 s -> s.reduce(Integer::sum));
303 assertCollect(data, Collectors.reducing(0, x -> x*2, Integer::sum),
304 s -> s.map(x -> x*2).reduce(0, Integer::sum));
307 s -> s.map(x -> x*2L).reduce(0L, Long::sum));
309 s -> s.map(x -> x*2).reduce(0, Integer::sum));
311 s -> s.map(x -> x * 2.0d).reduce(0.0d, Double::sum));
405 BinaryOperator<Integer> sum = Integer::sum;
[all …]
/libcore/jsr166-tests/src/test/java/jsr166/
DLongAdderTest.java33 assertEquals(0, ai.sum()); in testConstructor()
42 assertEquals(2, ai.sum()); in testAddAndSum()
44 assertEquals(-2, ai.sum()); in testAddAndSum()
53 assertEquals(-1, ai.sum()); in testDecrementAndsum()
55 assertEquals(-2, ai.sum()); in testDecrementAndsum()
64 assertEquals(1, ai.sum()); in testIncrementAndsum()
66 assertEquals(2, ai.sum()); in testIncrementAndsum()
75 assertEquals(2, ai.sum()); in testReset()
77 assertEquals(0, ai.sum()); in testReset()
86 assertEquals(2, ai.sum()); in testSumThenReset()
[all …]
DDoubleAdderTest.java33 assertEquals(0.0, ai.sum()); in testConstructor()
42 assertEquals(2.0, ai.sum()); in testAddAndSum()
44 assertEquals(-2.0, ai.sum()); in testAddAndSum()
53 assertEquals(2.0, ai.sum()); in testReset()
55 assertEquals(0.0, ai.sum()); in testReset()
64 assertEquals(2.0, ai.sum()); in testSumThenReset()
66 assertEquals(0.0, ai.sum()); in testSumThenReset()
78 assertEquals(-22.0, x.sum()); in testSerialization()
79 assertEquals(0.0, y.sum()); in testSerialization()
80 assertEquals(-22.0, z.sum()); in testSerialization()
[all …]
DAtomic8Test.java95 assertEquals(1L, a.getAndAccumulate(2L, Long::sum)); in testLongGetAndAccumulate()
96 assertEquals(3L, a.getAndAccumulate(3L, Long::sum)); in testLongGetAndAccumulate()
106 assertEquals(7L, a.accumulateAndGet(6L, Long::sum)); in testLongAccumulateAndGet()
107 assertEquals(10L, a.accumulateAndGet(3L, Long::sum)); in testLongAccumulateAndGet()
139 assertEquals(1, a.getAndAccumulate(2, Integer::sum)); in testIntGetAndAccumulate()
140 assertEquals(3, a.getAndAccumulate(3, Integer::sum)); in testIntGetAndAccumulate()
150 assertEquals(7, a.accumulateAndGet(6, Integer::sum)); in testIntAccumulateAndGet()
151 assertEquals(10, a.accumulateAndGet(3, Integer::sum)); in testIntAccumulateAndGet()
230 assertEquals(1L, a.getAndAccumulate(0, 2L, Long::sum)); in testLongArrayGetAndAccumulate()
231 assertEquals(3L, a.getAndAccumulate(0, 3L, Long::sum)); in testLongArrayGetAndAccumulate()
[all …]
DThreadLocalRandom8Test.java82 assertEquals(size, counter.sum()); in testIntsCount()
97 assertEquals(size, counter.sum()); in testLongsCount()
112 assertEquals(size, counter.sum()); in testDoublesCount()
182 assertEquals(size, counter.sum()); in testUnsizedIntsCount()
193 assertEquals(size, counter.sum()); in testUnsizedLongsCount()
204 assertEquals(size, counter.sum()); in testUnsizedDoublesCount()
215 assertEquals(size, counter.sum()); in testUnsizedIntsCountSeq()
226 assertEquals(size, counter.sum()); in testUnsizedLongsCountSeq()
237 assertEquals(size, counter.sum()); in testUnsizedDoublesCountSeq()
/libcore/ojluni/src/main/java/java/util/concurrent/atomic/
DLongAdder.java119 public long sum() { in sum() method in LongAdder
121 long sum = base; in sum() local
125 sum += a.value; in sum()
127 return sum; in sum()
159 long sum = base; in sumThenReset() local
164 sum += a.value; in sumThenReset()
169 return sum; in sumThenReset()
177 return Long.toString(sum()); in toString()
186 return sum(); in longValue()
194 return (int)sum(); in intValue()
[all …]
DDoubleAdder.java117 public double sum() { in sum() method in DoubleAdder
119 double sum = Double.longBitsToDouble(base); in sum() local
123 sum += Double.longBitsToDouble(a.value); in sum()
125 return sum; in sum()
157 double sum = Double.longBitsToDouble(base); in sumThenReset() local
164 sum += Double.longBitsToDouble(v); in sumThenReset()
168 return sum; in sumThenReset()
176 return Double.toString(sum()); in toString()
185 return sum(); in doubleValue()
193 return (long)sum(); in longValue()
[all …]
/libcore/ojluni/src/test/java/util/concurrent/tck/
DLongAdderTest.java56 assertEquals(0, ai.sum()); in testConstructor()
65 assertEquals(2, ai.sum()); in testAddAndSum()
67 assertEquals(-2, ai.sum()); in testAddAndSum()
76 assertEquals(-1, ai.sum()); in testDecrementAndsum()
78 assertEquals(-2, ai.sum()); in testDecrementAndsum()
87 assertEquals(1, ai.sum()); in testIncrementAndsum()
89 assertEquals(2, ai.sum()); in testIncrementAndsum()
98 assertEquals(2, ai.sum()); in testReset()
100 assertEquals(0, ai.sum()); in testReset()
109 assertEquals(2, ai.sum()); in testSumThenReset()
[all …]
DDoubleAdderTest.java56 assertEquals(0.0, ai.sum()); in testConstructor()
65 assertEquals(2.0, ai.sum()); in testAddAndSum()
67 assertEquals(-2.0, ai.sum()); in testAddAndSum()
76 assertEquals(2.0, ai.sum()); in testReset()
78 assertEquals(0.0, ai.sum()); in testReset()
87 assertEquals(2.0, ai.sum()); in testSumThenReset()
89 assertEquals(0.0, ai.sum()); in testSumThenReset()
101 assertEquals(-22.0, x.sum()); in testSerialization()
102 assertEquals(0.0, y.sum()); in testSerialization()
103 assertEquals(-22.0, z.sum()); in testSerialization()
[all …]
DAtomic8Test.java116 assertEquals(1L, a.getAndAccumulate(2L, Long::sum)); in testLongGetAndAccumulate()
117 assertEquals(3L, a.getAndAccumulate(3L, Long::sum)); in testLongGetAndAccumulate()
127 assertEquals(7L, a.accumulateAndGet(6L, Long::sum)); in testLongAccumulateAndGet()
128 assertEquals(10L, a.accumulateAndGet(3L, Long::sum)); in testLongAccumulateAndGet()
160 assertEquals(1, a.getAndAccumulate(2, Integer::sum)); in testIntGetAndAccumulate()
161 assertEquals(3, a.getAndAccumulate(3, Integer::sum)); in testIntGetAndAccumulate()
171 assertEquals(7, a.accumulateAndGet(6, Integer::sum)); in testIntAccumulateAndGet()
172 assertEquals(10, a.accumulateAndGet(3, Integer::sum)); in testIntAccumulateAndGet()
251 assertEquals(1L, a.getAndAccumulate(0, 2L, Long::sum)); in testLongArrayGetAndAccumulate()
252 assertEquals(3L, a.getAndAccumulate(0, 3L, Long::sum)); in testLongArrayGetAndAccumulate()
[all …]
DThreadLocalRandom8Test.java105 assertEquals(size, counter.sum()); in testIntsCount()
120 assertEquals(size, counter.sum()); in testLongsCount()
135 assertEquals(size, counter.sum()); in testDoublesCount()
205 assertEquals(size, counter.sum()); in testUnsizedIntsCount()
216 assertEquals(size, counter.sum()); in testUnsizedLongsCount()
227 assertEquals(size, counter.sum()); in testUnsizedDoublesCount()
238 assertEquals(size, counter.sum()); in testUnsizedIntsCountSeq()
249 assertEquals(size, counter.sum()); in testUnsizedLongsCountSeq()
260 assertEquals(size, counter.sum()); in testUnsizedDoublesCountSeq()
/libcore/benchmarks/src/benchmarks/
DArrayIterationBenchmark.java29 int sum = 0; in timeArrayIteration() local
31 sum += mArray[i].mSplat; in timeArrayIteration()
37 int sum = 0; in timeArrayIterationCached() local
42 sum += localArray[i].mSplat; in timeArrayIterationCached()
48 int sum = 0; in timeArrayIterationForEach() local
50 sum += a.mSplat; in timeArrayIterationForEach()
DArrayListIterationBenchmark.java31 int sum = 0; in timeArrayListIterationIndexed() local
35 sum += list.get(i).mSplat; in timeArrayListIterationIndexed()
41 int sum = 0; in timeArrayListIterationForEach() local
43 sum += a.mSplat; in timeArrayListIterationForEach()
DBigIntegerBenchmark.java55 BigInteger sum = BigInteger.ZERO; in inner() local
57 sum = sum.add(big.multiply(big)); in inner()
59 if (sum.and(BigInteger.valueOf(0x3fffffff)).intValue() != n) { in inner()
60 System.out.println("inner() got " + sum.and(BigInteger.valueOf(0x3fffffff)) in inner()
79 BigInteger sum = BigInteger.ZERO; in harmonic1000() local
81 sum = sum.add(scaledOne.divide(BigInteger.valueOf(i))); in harmonic1000()
83 return sum; in harmonic1000()
/libcore/ojluni/src/main/java/java/util/
DArrayPrefixHelpers.java197 T sum; in compute() local
201 sum = a[org]; in compute()
205 sum = t.in; in compute()
209 a[i] = sum = fn.apply(sum, a[i]); in compute()
212 sum = a[l]; in compute()
214 sum = fn.apply(sum, a[i]); in compute()
217 sum = t.in; in compute()
218 t.out = sum; in compute()
349 long sum; in compute() local
353 sum = a[org]; in compute()
[all …]
DDoubleSummaryStatistics.java65 private double sum; field in DoubleSummaryStatistics
102 sumWithCompensation(other.sum); in combine()
114 double velvel = sum + tmp; // Little wolf of rounding error in sumWithCompensation()
115 sumCompensation = (velvel - sum) - tmp; in sumWithCompensation()
116 sum = velvel; in sumWithCompensation()
153 double tmp = sum + sumCompensation; in getSum()
DIntSummaryStatistics.java67 private long sum; field in IntSummaryStatistics
86 sum += value; in accept()
99 sum += other.sum; in combine()
120 return sum; in getSum()
DLongSummaryStatistics.java68 private long sum; field in LongSummaryStatistics
97 sum += value; in accept()
111 sum += other.sum; in combine()
132 return sum; in getSum()
/libcore/benchmarks/src/benchmarks/regression/
DMutableIntBenchmark.java39 int sum = 0; in ARRAY() local
41 sum += value[0]; in ARRAY()
43 return sum; in ARRAY()
60 int sum = 0; in ATOMIC() local
62 sum += value.intValue(); in ATOMIC()
64 return sum; in ATOMIC()
/libcore/ojluni/src/test/java/util/stream/boottest/java/util/stream/
DStreamReuseTest.java197 IntStream::sum, IntStream::sum, in testTwoTerminals()
205 IntStream::sum, (IntStream s) -> s.mapToObj(i -> i), in testTerminalStream()
209 (IntStream s) -> s.mapToObj(i -> i), IntStream::sum, in testTerminalStream()
213 IntStream::sum, IntStream::distinct, in testTerminalStream()
217 IntStream::distinct, IntStream::sum, in testTerminalStream()
233 IntStream::iterator, IntStream::sum, in testTerminalIterator()
237 IntStream::sum, IntStream::iterator, in testTerminalIterator()
287 LongStream::sum, LongStream::sum, in testTwoTerminals()
295 LongStream::sum, (LongStream s) -> s.mapToObj(i -> i), in testTerminalStream()
299 (LongStream s) -> s.mapToObj(i -> i), LongStream::sum, in testTerminalStream()
[all …]
/libcore/support/src/test/java/tests/util/
DSummaryStatistics.java24 private double sum; field in SummaryStatistics
46 sum += value; in add()
53 return sum / numValues; in mean()
58 double shiftedMean = (sum - numValues * firstValue) / numValues; in var()
/libcore/luni/src/test/java/libcore/java/util/
DArraysTest.java583 int sum = Arrays.stream(sourceArray) in streamInt() local
585 .sum(); in streamInt()
586 assertEquals(size * (size - 1), sum); in streamInt()
629 .sum(); in streamIntStartEnd_Exceptions()
636 .sum(); in streamIntStartEnd_Exceptions()
643 .sum(); in streamIntStartEnd_Exceptions()
650 .sum(); in streamIntStartEnd_Exceptions()
657 .sum(); in streamIntStartEnd_Exceptions()
670 long sum = Arrays.stream(sourceArray) in streamLong() local
672 .sum(); in streamLong()
[all …]

1234