public final class MutableDouble extends Number implements Comparable<MutableDouble>, Mutable
Note: it's copied from Apache Commons Lang developed at The Apache Software Foundation (http://www.apache.org/), or under the Apache License 2.0. The methods copied from other products/frameworks may be modified in this class.
A mutabledouble wrapper.
Note that as MutableDouble does not extend Double, it is not treated by String.format as a Double parameter.
MutableDouble is NOT thread-safe.
Double,
Serialized Form| Modifier and Type | Method and Description |
|---|---|
void |
add(double operand)
Adds a value to the value of this instance.
|
double |
addAndGet(double delta)
Adds the given value to the current value.
|
int |
compareTo(MutableDouble other)
Compares this mutable to another in ascending order.
|
void |
decrement()
Decrements the value.
|
double |
decrementAndGet()
Decrements by one the current value.
|
double |
doubleValue()
Returns the value of this MutableDouble as a double.
|
boolean |
equals(Object obj)
Compares this object against the specified object.
|
float |
floatValue()
Returns the value of this MutableDouble as a float.
|
double |
getAndAdd(double delta)
Adds the given value to the current value.
|
double |
getAndDecrement()
Decrements by one the current value.
|
double |
getAndIncrement()
Increments by one the current value.
|
double |
getAndSet(double value)
Gets the and set.
|
double |
getValue()
Deprecated.
replace by
value(). |
int |
hashCode()
Returns a suitable hash code for this mutable.
|
void |
increment()
Increments the value.
|
double |
incrementAndGet()
Increments by one the current value.
|
int |
intValue()
Returns the value of this MutableDouble as an int.
|
boolean |
isInfinite()
Checks whether the double value is infinite.
|
boolean |
isNaN()
Checks whether the double value is the special NaN value.
|
long |
longValue()
Returns the value of this MutableDouble as a long.
|
static MutableDouble |
of(double value) |
double |
setAndGet(double value)
Sets the and get.
|
<E extends Exception> |
setIf(double newValue,
Throwables.DoubleBiPredicate<E> predicate)
Deprecated.
|
<E extends Exception> |
setIf(double newValue,
Throwables.DoublePredicate<E> predicate)
Set with the specified new value and returns
true if predicate returns true. |
void |
setValue(double value)
Sets the value.
|
void |
subtract(double operand)
Subtracts a value from the value of this instance.
|
String |
toString()
Returns the String value of this mutable.
|
double |
value() |
byteValue, shortValuepublic static MutableDouble of(double value)
value - public double value()
@Deprecated public double getValue()
value().public void setValue(double value)
public double getAndSet(double value)
value - public double setAndGet(double value)
value - public <E extends Exception> boolean setIf(double newValue, Throwables.DoublePredicate<E> predicate) throws E extends Exception
true if predicate returns true.
Otherwise just return false without setting the value to new value.E - newValue - predicate - - test the current value.E - the eE extends Exception@Deprecated public <E extends Exception> boolean setIf(double newValue, Throwables.DoubleBiPredicate<E> predicate) throws E extends Exception
true if predicate returns true.
Otherwise just return false without setting the value to new value.E - newValue - predicate - the first parameter is the current value, the second parameter is the new value.E - the eE extends Exceptionpublic boolean isNaN()
public boolean isInfinite()
public void increment()
public void decrement()
public void add(double operand)
public void subtract(double operand)
public final double getAndIncrement()
public final double getAndDecrement()
public final double incrementAndGet()
public final double decrementAndGet()
public final double getAndAdd(double delta)
delta - the value to addpublic final double addAndGet(double delta)
delta - the value to addpublic int intValue()
public long longValue()
public float floatValue()
floatValue in class Numberpublic double doubleValue()
doubleValue in class Numberpublic int compareTo(MutableDouble other)
compareTo in interface Comparable<MutableDouble>public boolean equals(Object obj)
true if and only if the argument
is not null and is a Double object that represents a double that has the identical
bit pattern to the bit pattern of the double represented by this object. For this purpose, two
double values are considered to be the same if and only if the method
Double.doubleToLongBits(double)returns the same long value when applied to each.
Note that in most cases, for two instances of class Double,d1 and d2,
the value of d1.equals(d2) is true if and only if
d1.doubleValue() == d2.doubleValue()
also has the value true. However, there are two exceptions:
d1 and d2 both represent Double.NaN, then the
equals method returns true, even though Double.NaN==Double.NaN has
the value false.
d1 represents +0.0 while d2 represents -0.0,
or vice versa, the equal test has the value false, even though
+0.0==-0.0 has the value true. This allows hashtables to operate properly.
public int hashCode()
Copyright © 2021. All rights reserved.