You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ps...@apache.org on 2004/09/21 05:02:34 UTC
cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/stat Frequency.java
psteitz 2004/09/20 20:02:34
Modified: math/src/java/org/apache/commons/math/stat Frequency.java
Log:
Modified addValue(Object) to convert Integers to Longs, completing (hopefully ;-) fix of problem with integral type conversions reported to commons-dev by Jon Langlois.
Revision Changes Path
1.29 +8 -4 jakarta-commons/math/src/java/org/apache/commons/math/stat/Frequency.java
Index: Frequency.java
===================================================================
RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/Frequency.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Frequency.java 19 Sep 2004 22:47:27 -0000 1.28
+++ Frequency.java 21 Sep 2004 03:02:34 -0000 1.29
@@ -93,12 +93,16 @@
* @throws IllegalArgumentException if <code>v</code> is not comparable.
*/
public void addValue(Object v) {
+ Object obj = v;
+ if (v instanceof Integer) {
+ obj = new Long(((Integer) v).longValue());
+ }
try {
- Long count = (Long) freqTable.get(v);
+ Long count = (Long) freqTable.get(obj);
if (count == null) {
- freqTable.put(v, new Long(1));
+ freqTable.put(obj, new Long(1));
} else {
- freqTable.put(v, new Long(count.longValue() + 1));
+ freqTable.put(obj, new Long(count.longValue() + 1));
}
} catch (ClassCastException ex) {
//TreeMap will throw ClassCastException if v is not comparable
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org