Maintains a frequency distribution.
Accepts int, long, char or Comparable values. New values added must be comparable to those that have been added, otherwise the add method will throw an IllegalArgumentException.
Integer values (int, long, Integer, Long) are not distinguished by type -- i.e. addValue(Long.valueOf(2)), addValue(2), addValue(2l)
all have the same effect (similarly for arguments to getCount,
etc.).
NOTE: byte and short values will be implicitly converted to int values by the compiler, thus there are no explicit overloaded methods for these primitive types.
char values are converted by addValue
to Character instances. As such, these values are not comparable to integral values, so attempts to combine integral types with chars in a frequency distribution will fail.
Float is not coerced to Double. Since they are not Comparable with each other the user must do any necessary coercion. Float.NaN and Double.NaN are not treated specially; they may occur in input and will occur in output if appropriate.
The values are ordered using the default (natural order), unless a Comparator
is supplied in the constructor.