commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz" <p...@steitz.com>
Subject RE: [Math] Frequency : Is int comparable to Integer through default comparator
Date Wed, 11 Aug 2004 20:45:11 GMT
The contract as stated in the javadoc is:
 
 * Maintains a frequency distribution.
* <p>
* Accepts int, long, char or Object values.  New values added must be 
* comparable to those that have been added, otherwise the add method will 
* throw an IllegalArgumentException.  
* <p>
* Integer values (int, long, Integer, Long) are not distinguished by type -- 
* i.e. <code>addValue(new Long(2)), addValue(2), addValue(2l)</code> all have
* the same effect (similarly for arguments to <code>getCount,</code> etc.).
* <p>
* The values are ordered using the default (natural order), unless a  
* <code>Comparator</code>is supplied in the constructor.

Integer values are all stored as Long instances in the TreeMap.  The problem is in addValue(object),
which should treat Integer instances specially.  I will fix this.  Thanks for reporting the
problem.
 
Phil
Mime
View raw message