// Priority queue element

public class PQElement implements Comparable {
    private Object item;
    private int priority;
    
    public PQElement(Object o, int p) {
	item = o;
	priority = p;
    }

    public int getPriority() {
	return priority;
    }

    public void setPriority(int p) {
	priority = p;
    }

    public Object getItem() {
	return item;
    }

    public String toString() {
	return  "("+item+","+priority+")";
    }

    // return (this.p - o.p)
    // so, return pos means this.p > o.p
    //     return neg means this.p < o.p
    public int compareTo(Object o) {
	if (o instanceof PQElement)
	    return (priority - ((PQElement)o).priority);
	else { 
	    System.out.println("Cannot compare elements!");
	    return 0;
	}
    }
}
