Merge remote-tracking branch 'origin/pr/58' This closes #58
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/843fbfbc Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/843fbfbc Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/843fbfbc Branch: refs/heads/master Commit: 843fbfbc3428819dc0763fa470a8af64c0e74775 Parents: ed1ce82 31e3a88 Author: Bruno P. Kinoshita <[email protected]> Authored: Wed May 10 19:56:52 2017 +1200 Committer: Bruno P. Kinoshita <[email protected]> Committed: Wed May 10 19:56:52 2017 +1200 ---------------------------------------------------------------------- .../apache/commons/math4/stat/Frequency.java | 399 +++---------------- .../apache/commons/math4/stat/StatUtils.java | 8 +- .../RandomUtilsDataGeneratorAbstractTest.java | 10 +- .../commons/math4/stat/FrequencyTest.java | 319 +++++---------- 4 files changed, 163 insertions(+), 573 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/843fbfbc/src/main/java/org/apache/commons/math4/stat/Frequency.java ---------------------------------------------------------------------- diff --cc src/main/java/org/apache/commons/math4/stat/Frequency.java index dfcca5a,72368ff..66629ce --- a/src/main/java/org/apache/commons/math4/stat/Frequency.java +++ b/src/main/java/org/apache/commons/math4/stat/Frequency.java @@@ -35,40 -34,16 +34,18 @@@ import org.apache.commons.math4.util.Ma /** * Maintains a frequency distribution. - * <p> - * 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.</p> - * <p> - * Integer values (int, long, Integer, Long) are not distinguished by type -- - * i.e. <code>addValue(Long.valueOf(2)), addValue(2), addValue(2l)</code> all have - * the same effect (similarly for arguments to <code>getCount,</code> etc.).</p> - * <p>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.</p> - * <p> - * char values are converted by <code>addValue</code> 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. - * </p> - * <p> - * 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. - * </p> -- * <p> -- * The values are ordered using the default (natural order), unless a ++ * ++ * <p>The values are ordered using the default (natural order), unless a * <code>Comparator</code> is supplied in the constructor.</p> + * ++ * @param <T> a comparable type used in the frequency distribution */ - public class Frequency implements Serializable { + public class Frequency<T extends Comparable<T>> implements Serializable { /** Serializable version identifier */ - private static final long serialVersionUID = -3845586908418844111L; - + private static final long serialVersionUID = 605878194679954450L; /** underlying collection */ - private final SortedMap<Comparable<?>, Long> freqTable; + private final SortedMap<T, Long> freqTable; /** * Default constructor. @@@ -626,10 -329,10 +331,11 @@@ /** * A Comparator that compares comparable objects using the - * natural order. Copied from Commons Collections ComparableComparator. - * @param <T> the type of the objects compared + * natural order. Copied from Commons Collections ComparableComparator. - * @param <T> the type of the objects compared ++ * ++ * @param <U> the type of the objects compared */ - private static class NaturalComparator<T extends Comparable<T>> implements Comparator<Comparable<T>>, Serializable { + private static class NaturalComparator<U extends Comparable<U>> implements Comparator<U>, Serializable { /** Serializable version identifier */ private static final long serialVersionUID = -3852193713161395148L; http://git-wip-us.apache.org/repos/asf/commons-math/blob/843fbfbc/src/main/java/org/apache/commons/math4/stat/StatUtils.java ----------------------------------------------------------------------
