lu.cs.co.util
Class ObjectWithPriority
java.lang.Object
|
+--lu.cs.co.util.ObjectWithPriority
- public class ObjectWithPriority
- extends Object
- implements Comparable
An object with a priority. This class implements the Comparable
interface. Useful for inserting objects into a PriorityQueue with
an explicit priority.
- See Also:
Comparable
obj
public Object obj
prio
public int prio
ObjectWithPriority
public ObjectWithPriority(Object o,
int p)
- Constructs an tuple of a specified priority
compareTo
public int compareTo(ObjectWithPriority o)
- Compares this ObjectWithPriority to another object.
- Parameters:
o - the ObjectWithPriority to be compared- Returns:
- -1, 0, or +1, if the argument has higher, the same, or
smaller priority than this ObjectWithPriority
compareTo
public int compareTo(Object o)
- Compares this ObjectWithPriority to another object. if the
argument is an ObjectWithPriority this function behaves like
compareTo(ObjectWithPriority). Otherwise, it throws a
ClassCastException.
- Specified by:
- compareTo in interface Comparable
- Parameters:
o - the ObjectWithPriority to be compared- Returns:
- -1, 0, or +1, if the argument has higher, the same, or
smaller priority than this ObjectWithPriority
- Throws:
- ClassCastException - if the argument is not an ObjectWithPriority