I'm trying to insert sorted values into a queue in Java. I've created a compareTo method and need help adding it to the Queue. The compareTo method is in one class and the queue is in a different class.
compareTo method:
public int compareTo(Event cmp) {
if(getArrTime() > cmp.arrTime) {
return 1;
}
else if(getArrTime() < cmp.arrTime) {
return -1;
}
else {
return 0;
}
}
This is what I'm trying to do for the insert method:
public void enque(Object insertSort) {
//if compareTo is greater than param, append to the front
//if equal, use event type. If it's 'A' append before 'D'
//if compareTo is less than the param, add to end
//return list
}