Browse Source

Implementation poll

T_SS20_Queue
chris 3 years ago
parent
commit
813811da43
  1. 18
      SimplePriorityQueue/src/testat_g11/SimplePriorityQueue.java

18
SimplePriorityQueue/src/testat_g11/SimplePriorityQueue.java

@ -49,8 +49,22 @@ public class SimplePriorityQueue<T extends Ticket> implements IPriorityQueue<T>
// Methode incrementAge() erhöht (Siehe Ticket im Paket testat_g11)
@Override
public T poll() {
// TODO Auto-generated method stub
return null;
if (size == 0) {
return null;
}
T tick = tickets[0];
for (int i = 1; i < size; i++) {
if (prioDet.calculate(tickets[i]) > prioDet.calculate(tick)) {
tick.incrementAge();
tick = tickets[i];
} else {
tickets[i].incrementAge();
}
}
remove(tick);
return tick;
}
// True: Ticket t ist enthalten, false sonst

Loading…
Cancel
Save