commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-483) Add ComparisonUtils to Commons Lang
Date Tue, 16 Aug 2011 06:38:27 GMT

    [ https://issues.apache.org/jira/browse/LANG-483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13085564#comment-13085564
] 

Henri Yandell commented on LANG-483:
------------------------------------

I'm not a fan of the ComprisonResult class; not without understanding the value in needing
the index where a value was found. It seems like a overlapping use case (i.e. some will want
index, some will want min value; few will want both at the same time and fewer will need performance
and want to roll their own).

The current (migrated over from Collections) method is:

    public static <E> E min(E o1, E o2, Comparator<E> comparator) {
    public static <E> E max(E o1, E o2, Comparator<E> comparator) {

ObjectUtils currently has:

    public static <T extends Comparable<? super T>> T min(T... values) {
    public static <T extends Comparable<? super T>> T max(T... values) {
    public static <T extends Comparable<? super T>> int compare(T c1, T c2) {
    public static <T extends Comparable<? super T>> int compare(T c1, T c2, boolean
nullGreater) {
    public static <T extends Comparable<? super T>> T median(T... items) {
    public static <T> T median(Comparator<T> comparator, T... items) {

Merging these seems to make sense. The latter went out in 3.0.1, so that suggests ObjectUtils
gets to be the location for the code. 

Looking at ObjectUtils, a min with a Comparator and a max with a Comparator seem missing.
Then also need to consider adding the additional 6 Collection<T> methods.

> Add ComparisonUtils to Commons Lang
> -----------------------------------
>
>                 Key: LANG-483
>                 URL: https://issues.apache.org/jira/browse/LANG-483
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>            Reporter: Benjamin McCann
>             Fix For: 3.0.2
>
>         Attachments: ComparisonUtils.java, ComparisonUtilsTest.java
>
>
> It'd be impossible to guess how many times code as been written to find the position
of the maximum element in an array or the value of the minimum element in a list, etc.  This
class will handle all of that.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message