Interface LongAdder
- All Known Implementing Classes:
AtomicLongLongAdder
,JreLongAdder
public interface LongAdder
Interface mirroring the
LongAdder
API, with implementation
that varies based on availability of LongAdder
. This offers
compatibility for Android 21 without compromising performance in runtimes where LongAdder
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
(long x) Add the given value.default void
Equivalent toadd(-1)
.default double
Returns thesum()
as adouble
after a widening primitive conversion.default float
Returns thesum()
as afloat
after a widening primitive conversion.default void
Equivalent toadd(1)
.default int
intValue()
Returns thesum()
as aint
after a narrowing primitive conversion.default long
Equivalent tosum()
.void
reset()
Resets the variables maintaining the sum to zero.long
sum()
Returns the current sum.long
-
Method Details
-
increment
default void increment()Equivalent toadd(1)
.- See Also:
-
decrement
default void decrement()Equivalent toadd(-1)
.- See Also:
-
add
void add(long x) Add the given value.- Parameters:
x
- the value to add- See Also:
-
sum
long sum()Returns the current sum.- See Also:
-
reset
void reset()Resets the variables maintaining the sum to zero.- See Also:
-
sumThenReset
long sumThenReset()- Returns:
- the sum
- See Also:
-
longValue
default long longValue()Equivalent tosum()
.- Returns:
- the sum
- 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 widening primitive conversion.- See Also:
-
doubleValue
default double doubleValue()Returns thesum()
as adouble
after a widening primitive conversion.- See Also:
-