[
https://issues.apache.org/jira/browse/MATH-473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981379#action_12981379
]
Phil Steitz commented on MATH-473:
----------------------------------
Patrick is correct that the reason that TreeMap is used (and values must
implement Comparable) is to meaningfully support cumulative counts and
percentages. The original version of this class did not support these and used
a o.a.c.collections.HashBag as backing store.
I understand the performance and flexibility benefit you are talking about,
Dan. I think it would be best supported in a different class, though, rather
than as a configuration option for Frequency. Frequency is one of the few
classes in Commons Math that does not separate interface from implementation
and this is a good example of why we did that elsewhere. I would be +1 to
refactoring to define interfaces for a) the current impl and b) the "stripped
down" impl that does not require values to implement Comparable and does not
support cum stats. With the interfaces separated, a new class implementing the
reduced interface would satisfy this enhancement request. An abstract base
class could be introduced providing code common to both impls (if that turns
out to be useful).
> Frequency: new option: NON-sorted
> ---------------------------------
>
> Key: MATH-473
> URL: https://issues.apache.org/jira/browse/MATH-473
> Project: Commons Math
> Issue Type: Improvement
> Reporter: Dan Checkoway
>
> I have a request for enhancement on org.apache.commons.math.stat.Frequency.
> I would like to be able to specify that the the backing map NOT be sorted.
> Right now it uses TreeMap. I would like to have the option of specifying
> that sorting is not important, and would in fact hinder performance, and a
> plain old HashMap should be used instead.
> i.e. constructor such as:
> public Frequency(boolean sorted);
> If sorted is true, use a TreeMap. If sorted is false, use a HashMap. Is
> this feasible? I'd be happy to contribute a patch if that would help.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.