Class MultiComparator<T>

java.lang.Object
org.uma.jmetal.util.comparator.MultiComparator<T>
All Implemented Interfaces:
Comparator<T>

public class MultiComparator<T> extends Object implements 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 Details

  • Constructor Details

    • MultiComparator

      public MultiComparator(List<Comparator<T>> comparatorList)
      Constructor
      Parameters:
      comparatorList -
    • MultiComparator

      public MultiComparator()
  • Method Details

    • add

      public MultiComparator<T> add(Comparator<T> comparator)
    • compare

      public int compare(T o1, T o2)
      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:
      compare in interface Comparator<T>
      Parameters:
      o1 - the first element to compare
      o2 - the second element to compare
      Returns:
      -1 if o1 is smaller than o2, 1 if o2 is bigger than o2, and 0 otherwise
    • getComparatorList

      public List<? extends Comparator<T>> getComparatorList()
      Returns:
      the list of comparators