Class FixedOrderComparator<T>

java.lang.Object
org.moeaframework.util.FixedOrderComparator<T>
Type Parameters:
T - the type of elements being sorted
All Implemented Interfaces:
Comparator<T>

public class FixedOrderComparator<T> extends Object implements Comparator<T>
Sorts elements according to a fixed order. The order is defined by mapping elements to integers and sorting based on the numeric value. Elements not defined in the mapping are always sorted last.
  • Field Details

    • LAST

      public static final int LAST
      Constant used to place an element at the end of the sorted collection. If multiple elements map to this value, their ordering is undefined.
      See Also:
  • Constructor Details

    • FixedOrderComparator

      public FixedOrderComparator(Map<T,Integer> order)
      Creates a new fixed order comparator.
      Parameters:
      order - mapping defining the ordering of elements
  • Method Details