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

Field Summary
 Object obj
           
 int prio
           
 
Constructor Summary
ObjectWithPriority(Object o, int p)
          Constructs an tuple of a specified priority
 
Method Summary
 int compareTo(Object o)
          Compares this ObjectWithPriority to another object.
 int compareTo(ObjectWithPriority o)
          Compares this ObjectWithPriority to another object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

obj

public Object obj

prio

public int prio
Constructor Detail

ObjectWithPriority

public ObjectWithPriority(Object o,
                          int p)
Constructs an tuple of a specified priority
Method Detail

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