To avoid adding problem with which value should I init the value of rule_prio ? ...1) rule_prio.add(int x , Rule r) doesn't work too; 2)initializing it with an existing EList doesn't work too 3) is temp.remove(int) is really deleting the value or modify only the pointer ????
private static EList<Rule> priorite(EList<Rule> R) {
Rule r;
int min ;
int p=-1;
int last_p = -1;
EList<Rule> rule_prio = null;
EList<Rule> temp = R;
while(temp.isEmpty()==false)
{
min=temp.get(0).getPriority();
for (int i=1; i<temp.size(); i++)
{
r = temp.get(i);
if (r.getPriority() < min)
{
min = r.getPriority();
p = i;
}
}
if (p!= -1 && p!= last_p)
{
rule_prio.add(temp.get(p));
temp.remove(p);
last_p = p;
}
}
return rule_prio;
}
Or it could be rule model the problem ?