Package org.uma.jmetal.util.comparator
Class MultiComparator<T>
java.lang.Object
org.uma.jmetal.util.comparator.MultiComparator<T>
- All Implemented Interfaces:
Comparator<T>
- Version:
- 1.0 This class aims to implement an interface for MultiComparators. Multicomparators are comparators that underneath make use of a list of comparators to possibly break the ties between solutions
- Author:
- Juanjo
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(Comparator<T> comparator) intCompare two objects based on a list of comparators.List<? extends Comparator<T>> Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
comparatorList
-
-
Constructor Details
-
MultiComparator
-
MultiComparator
public MultiComparator()
-
-
Method Details
-
add
-
compare
Compare two objects based on a list of comparators. It performs a lexicographical comparison as follows:o1 is smaller than o2 if exist an index i, within the interval [0,comparatorList.size()) s.t. comparatorList.get(i).compare(o1,o2)==-1 and for all j, s.t. jinvalid input: '<'i, then comparatorList.get(j).compare(o1,o2)==0.
Conversely, o1 is bigger than o2 if exist an index i, within the interval [0,comparatorList.size()) s.t. comparatorList.get(i).compare(o1,o2)==1 and for all j, s.t. jinvalid input: '<'i, then comparatorList.get(j).compare(o1,o2)==0.
Finally o1 cannot be said smaller or bigger than o2 if none of the previous two cases are true.
- Specified by:
comparein interfaceComparator<T>- Parameters:
o1- the first element to compareo2- the second element to compare- Returns:
- -1 if o1 is smaller than o2, 1 if o2 is bigger than o2, and 0 otherwise
-
getComparatorList
- Returns:
- the list of comparators
-