public void testInteger() {
Frequency freq = new Frequency();
for (int i=0; i<10; i++) {
freq.addValue(new Integer(i));
}
assertTrue(freq.getCumFreq(new Integer(5)) == 5);
}
For some reason, the implementation of Frequency.addValue(Integer) converts the value into a Long before storing it in the internal TreeMap. Subsequent calls to getCount() and getPct() work okay, but valuesIterator() returns an Iterator of Longs and getCumPct()/getCumFreq() return 0 (because the internal Comparator is throwing ClassCastExceptions).
If there isn't a reason to convert everything to Longs, the following patch will fix the problem:
--- Frequency.java.orig 2004-09-14 12:46:06.945880000 -0400
+++ Frequency.java 2004-09-14 12:49:02.878859200 -0400
@@ -121,7 +121,7 @@
* @param v the value to add.
*/
public void addValue(Integer v) {
- addValue(new Long(v.longValue()));
+ addValue((Object) v);
}/**
- Jon Langlois
-- This electronic transmission is strictly confidential to NetIDEAS, Inc. and intended solely for the addressee. It may contain information, which is covered by legal, professional, or other privilege. If you are not the intended addressee, or someone authorized by the intended addressee to receive transmissions on the behalf of the addressee, you must not retain, disclose in any form, copy or take any action in reliance on this transmission. If you have received this transmission in error, please notify us as soon as possible and destroy this message.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
