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 Detail

      • priority

        double priority()
        The sort priority of the object.
        See Also:
        Priority
      • compare

        static <T extends Prioritized<T>> int compare​(Prioritized<T> p1,
                                                      Prioritized<T> p2)
        Compares two Prioritized objects, based on their priority() value. Higher priorities (e.g. Priority.HIGH) compare less than lower ones (e.g. Priority.LOW, so that a natural sort of Prioritized objects will result in the higher priority items earlier in the sorted list. If null is passed as an argument, that argument's priority is considered to be negative infinity—i.e., lower priority than all non-null objects, resulting in all null values 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) or Comparator.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 than p2's, 1 if p2's priority is higher than p1's, or 0 if they have the same priority.