Interface DoubleAdder
- All Known Implementing Classes:
AtomicLongDoubleAdder
,JreDoubleAdder
public interface DoubleAdder
Interface mirroring the
DoubleAdder
API, with implementation
that varies based on availability of DoubleAdder
. This offers
compatibility for Android 21 without compromising performance in runtimes where DoubleAdder
is available.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double x) Add the given value.default double
Equivalent tosum()
.default float
Returns thesum()
as afloat
after a narrowing primitive conversion.default int
intValue()
Returns thesum()
as aint
after a narrowing primitive conversion.default long
Returns thesum()
as along
after a narrowing primitive conversion.void
reset()
Resets the variables maintaining the sum to zero.double
sum()
Returns the current sum.double
-
Method Details
-
add
void add(double x) Add the given value.- Parameters:
x
- the value to add- See Also:
-
sum
double sum()Returns the current sum.- See Also:
-
reset
void reset()Resets the variables maintaining the sum to zero.- See Also:
-
sumThenReset
double sumThenReset()- Returns:
- the sum
- See Also:
-
longValue
default long longValue()Returns thesum()
as along
after a narrowing primitive conversion.- See Also:
-
intValue
default int intValue()Returns thesum()
as aint
after a narrowing primitive conversion.- See Also:
-
floatValue
default float floatValue()Returns thesum()
as afloat
after a narrowing primitive conversion.- See Also:
-
doubleValue
default double doubleValue()Equivalent tosum()
.- Returns:
- the sum
- See Also:
-