commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Morgan Delagrange" <mdela...@yahoo.com>
Subject Re: [collections] ReverseComparator
Date Tue, 19 Mar 2002 19:29:59 GMT
Do we need an empty constructor?  If it does not produce desirable
behaviour, why not can it?

----- Original Message -----
From: "Henri Yandell" <bayard@generationjava.com>
To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
Sent: Tuesday, March 19, 2002 11:11 AM
Subject: Re: [collections] ReverseComparator


>
> Functionality wise, I feel that Michael's proposed change is a negative
> move. However he is absolutely right in all of his points. The current -1
> does break the Comparator contract, the -1* is unnecessary coding, making
> the constructor take ComparableComparator is then no different from
> reverseOrder, and the name then does make more sense as InverseComparator.
>
> It's like a stack of dominoes :) Each point seems not necessarily true
> until you realise each one leads to the next. So I'm:
>
> +1 on removing the -1*.
> +1 on killing the current empty constructor.
> +0 on using ComparableComparator which simulates reverseOrder
functionality.
>    It feels bad to replicate this, but we need an empty constructor.
> +0 on the name of the class. It does behave more as an InverseComparator
>    from a mathematical point of view (which I share), but Reverse does
>    seem more readable.
>
> Hen
>
>
> On Tue, 19 Mar 2002, Morgan Delagrange wrote:
>
> > Michael suggested that the no-op constructor essentially behave like
this:
> >
> >   ReverseComparator() {
> >       this(ComparableComparator.getInstance());
> >   }
> >
> > What do you think, Hen?  Do you think that is preferable, or do you
prefer
> > your initial behaviour (reversing the List).
> >
> >
> > ----- Original Message -----
> > From: "Henri Yandell" <bayard@generationjava.com>
> > To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
> > Sent: Tuesday, March 19, 2002 7:50 AM
> > Subject: Re: [collections] ReverseComparator
> >
> >
> > >
> > > I'm happy with the name Inverse as it is more what the comparator
does.
> > > Reverse makes it easier to see how it can be used for one case, but
will
> > > hide other meanings.
> > >
> > > Why does this exist over Collections.reverseOrder? Because the Sun
version
> > > is limited. Why can I only reverse Comparables? Really there should be
a
> > > Collections.reverseOrder(Comparator) as well.
> > >
> > > Hen
> > >
> > > > I agree that reverse is common terminology when sorting, but I
disagree
> > > > that sorting is intrinsicly what a comparator does. While sorting is
> > > > probably the most common use-case for comparators, the comparator
itself
> > > > does not do any sorting.  It compares objects and returns a
negative,
> > zero
> > > > value, or positive result.  It doesn't rearrange, reverse, order, or
> > > > "sort".  It just compares two objects. This particular comparator
> > > > "inverses" the result of the compare to be a positive, zero value,
or
> > > > negative result (respectively).  I use "inverse" here in its
> > mathematical
> > > > sense of inverting the result, since that's all this comparator is
> > doing.
> > > >
> > > > I'm not going to argue this anymore though.  I've changed my
position --
> > > > why is this class even included in commons when the JDK provides a
> > > > reverse/inverse comparator already?  @see Collections.reverseOrder()
> > > >
> > > > regards,
> > > > michael
> > > >
> > > > > "Michael A. Smith" wrote:
> > > > > >[snip]
> > > > > > Additionally, I think that "InverseComparator" is a more
appropriate
> > name,
> > > > > > as "inverse" has a more direct meaning (to me at least).
Inverse
> > has the
> > > > > > mathematical meaning of the opposite sign which is exactly what
this
> > > > > > comparator does.  Reverse, on the other hand, implies switching
the
> > order
> > > > > > of something, the comparator isn't really switching the order
> > (although a
> > > > > > collection using the comparator may be "reversed" if it uses
the
> > "inverse"
> > > > > > comparator).
> > > > > >
> > > > > > Thoughts?
> > > > > >[snip]
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > <mailto:commons-dev-help@jakarta.apache.org>
> > > >
> > > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <mailto:commons-dev-help@jakarta.apache.org>
> >
> >
> > _________________________________________________________
> > Do You Yahoo!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> >
> > --
> > To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>
> >
> >
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message