Module org.scijava.priority
Package org.scijava.priority
Interface Prioritized<T extends Prioritized<T>>
-
- All Superinterfaces:
Comparable<T>
public interface Prioritized<T extends Prioritized<T>> extends Comparable<T>
An object that can be sorted according to priority.- Author:
- Curtis Rueden
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <T extends Prioritized<T>>
intcompare(Prioritized<T> p1, Prioritized<T> p2)Compares twoPrioritizedobjects, based on theirpriority()value.default intcompareTo(T that)doublepriority()The sort priority of the object.
-
-
-
Method Detail
-
priority
double priority()
The sort priority of the object.- See Also:
Priority
-
compareTo
default int compareTo(T that)
- Specified by:
compareToin interfaceComparable<T extends Prioritized<T>>
-
compare
static <T extends Prioritized<T>> int compare(Prioritized<T> p1, Prioritized<T> p2)
Compares twoPrioritizedobjects, based on theirpriority()value. Higher priorities (e.g.Priority.HIGH) compare less than lower ones (e.g.Priority.LOW, so that a natural sort ofPrioritizedobjects will result in the higher priority items earlier in the sorted list. Ifnullis passed as an argument, that argument's priority is considered to be negative infinity—i.e., lower priority than all non-nullobjects, resulting in allnullvalues being sorted to the end of the list.Note: this method provides a natural ordering that may be inconsistent with equals. That is, two unequal objects may often have the same priority, and thus return 0 when compared in this fashion. Hence, if this method is used as a basis for implementing
Comparable.compareTo(T)orComparator.compare(T, T), that implementation may want to impose logic beyond that of this method, for breaking ties, if a total ordering consistent with equals is always required.- Parameters:
p1- The first prioritized object to compare.p2- The second prioritized object to compare.- Returns:
- -1 if
p1's priority is higher thanp2's, 1 ifp2's priority is higher thanp1's, or 0 if they have the same priority.
-
-