From: Mailing l. f. S. c. m. <jtc...@li...> - 2015-09-04 23:19:20
|
Revision: 3472 http://sourceforge.net/p/jtcfrost/code/3472 Author: kevloral Date: 2015-09-04 23:19:18 +0000 (Fri, 04 Sep 2015) Log Message: ----------- [ADD] First contents migrated to the new frost.utils artifact. Added Paths: ----------- frost/trunk/frost.util/src/main/java/frost/util/ReverseComparator.java Copied: frost/trunk/frost.util/src/main/java/frost/util/ReverseComparator.java (from rev 3458, frost/trunk/frost.core/src/main/java/frost/util/ReverseComparator.java) =================================================================== --- frost/trunk/frost.util/src/main/java/frost/util/ReverseComparator.java (rev 0) +++ frost/trunk/frost.util/src/main/java/frost/util/ReverseComparator.java 2015-09-04 23:19:18 UTC (rev 3472) @@ -0,0 +1,46 @@ +/* + ReverseComparator.java / Frost + Copyright (C) 2003 Frost Project <jtcfrost.sourceforge.net> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +package frost.util; + +import java.util.*; + +/** + * This class implements a comparator that is the reverse of the one passed as the + * parameter of the constructor. + */ +public class ReverseComparator<T> implements Comparator<T> { + + private Comparator<T> delegate; + + /** + * @param newDelegate + */ + public ReverseComparator(Comparator<T> newDelegate) { + super(); + delegate = newDelegate; + } + + /* (non-Javadoc) + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + public int compare(T o1, T o2) { + return -delegate.compare(o1, o2); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |