Ciao a tutti...ho un problema di ordinamento di una PriorityQueue
private PriorityQueue<Elemento> ListaAttesa ;
private class Elemento implements Comparable{
private int id;
private Object[]M;
private Thread T;
public Elemento(int id,Object[]M,Thread T){
this.id=id;
this.M=M;
this.T=T;}
public int getId(){
return id;
}
public Object[] getM(){
return M;
}
public Thread getThread(){
return T;
}
public int compareTo( Object o ){
Elemento e = (Elemento)o;
if (this.M.length > e.M.length ){
return -1;
}
if (this.M.length == e.M.length ){
if(this.id < e.id) return -1;
if(this.id > e.id) return 1;
}
return 1;
}//compareTo
}
Quello che vorrei è praticamente che nella mia PriorityQueue i dati siano ordinati in base alla lunghezza del vettore M ed, in caso di lunghezza uguale, in base ad id crescente.
Questo che ho scritto non mi fa quello che dovrebbe. Dove sbaglio? grazie