5 |
|
*/ |
6 |
|
|
7 |
|
package jsr166e; |
8 |
– |
import java.io.IOException; |
8 |
|
import java.io.Serializable; |
10 |
– |
import java.io.ObjectInputStream; |
11 |
– |
import java.io.ObjectOutputStream; |
9 |
|
|
10 |
|
/** |
11 |
|
* One or more variables that together maintain a running {@code double} |
16 |
|
* current maximum across the variables maintaining updates. |
17 |
|
* |
18 |
|
* <p>This class extends {@link Number}, but does <em>not</em> define |
19 |
< |
* methods such as {@code hashCode} and {@code compareTo} because |
20 |
< |
* instances are expected to be mutated, and so are not useful as |
21 |
< |
* collection keys. |
19 |
> |
* methods such as {@code equals}, {@code hashCode} and {@code |
20 |
> |
* compareTo} because instances are expected to be mutated, and so are |
21 |
> |
* not useful as collection keys. |
22 |
|
* |
23 |
|
* <p><em>jsr166e note: This class is targeted to be placed in |
24 |
< |
* java.util.concurrent.atomic<em> |
24 |
> |
* java.util.concurrent.atomic.</em> |
25 |
|
* |
26 |
+ |
* @since 1.8 |
27 |
|
* @author Doug Lea |
28 |
|
*/ |
29 |
|
public class DoubleMaxUpdater extends Striped64 implements Serializable { |
72 |
|
|
73 |
|
/** |
74 |
|
* Returns the current maximum. The returned value is |
75 |
< |
* <em>NOT</em> an atomic snapshot: Invocation in the absence of |
75 |
> |
* <em>NOT</em> an atomic snapshot: invocation in the absence of |
76 |
|
* concurrent updates returns an accurate result, but concurrent |
77 |
|
* updates that occur while the value is being calculated might |
78 |
|
* not be incorporated. |
137 |
|
|
138 |
|
/** |
139 |
|
* Returns the String representation of the {@link #max}. |
140 |
< |
* @return the String representation of the {@link #max}. |
140 |
> |
* @return the String representation of the {@link #max} |
141 |
|
*/ |
142 |
|
public String toString() { |
143 |
|
return Double.toString(max()); |
154 |
|
|
155 |
|
/** |
156 |
|
* Returns the {@link #max} as a {@code long} after a |
157 |
< |
* primitive conversion. |
157 |
> |
* narrowing primitive conversion. |
158 |
|
*/ |
159 |
|
public long longValue() { |
160 |
|
return (long)max(); |
162 |
|
|
163 |
|
/** |
164 |
|
* Returns the {@link #max} as an {@code int} after a |
165 |
< |
* primitive conversion. |
165 |
> |
* narrowing primitive conversion. |
166 |
|
*/ |
167 |
|
public int intValue() { |
168 |
|
return (int)max(); |
170 |
|
|
171 |
|
/** |
172 |
|
* Returns the {@link #max} as a {@code float} |
173 |
< |
* after a primitive conversion. |
173 |
> |
* after a narrowing primitive conversion. |
174 |
|
*/ |
175 |
|
public float floatValue() { |
176 |
|
return (float)max(); |
182 |
|
s.writeDouble(max()); |
183 |
|
} |
184 |
|
|
185 |
< |
private void readObject(ObjectInputStream s) |
186 |
< |
throws IOException, ClassNotFoundException { |
185 |
> |
private void readObject(java.io.ObjectInputStream s) |
186 |
> |
throws java.io.IOException, ClassNotFoundException { |
187 |
|
s.defaultReadObject(); |
188 |
|
busy = 0; |
189 |
|
cells = null; |