Package org.moeaframework.util
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>
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant used to place an element at the end of the sorted collection. -
Constructor Summary
ConstructorsConstructorDescriptionFixedOrderComparator(Map<T, Integer> order) Creates a new fixed order comparator. -
Method Summary
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
-
LAST
public static final int LASTConstant 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
Creates a new fixed order comparator.- Parameters:
order- mapping defining the ordering of elements
-
-
Method Details
-
compare
- Specified by:
comparein interfaceComparator<T>
-