-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMutableDouble.java
53 lines (48 loc) · 1.01 KB
/
MutableDouble.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Wrapper class to enable the usage of a mutable 'Double' when dealing with map.
*
* @author M. Habib Rosyad
*/
public class MutableDouble {
private double value;
/**
* Initialize with 0.
*/
public MutableDouble() {
value = 0;
}
/**
* Initialize with a value.
*
* @param value
*/
public MutableDouble(double value) {
this.value = value;
}
/**
* Add a value to the current value.
*
* @param value add current value by this value
*/
public void add(double value) {
this.value += value;
}
/**
* Get the value.
*
* @return the value
*/
public double getValue() {
return value;
}
/**
* Set the value.
*
* @param value set the current value into this
* @return instance of this object to enable chaining.
*/
public MutableDouble setValue(double value) {
this.value = value;
return this;
}
}