Puts a event to the queue in the right place @param ee The event to put to the queue
(ExternalEvent ee)
| 76 | * @param ee The event to put to the queue |
| 77 | */ |
| 78 | private void putToQueue(ExternalEvent ee) { |
| 79 | double eeTime = ee.getTime(); |
| 80 | |
| 81 | for (int i=0, n=this.updates.size(); i<n; i++) { |
| 82 | double time = updates.get(i).getTime(); |
| 83 | if (time == eeTime) { |
| 84 | return; // update with the given time exists -> no need for new |
| 85 | } |
| 86 | else if (eeTime < time) { |
| 87 | this.updates.add(i, ee); |
| 88 | return; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /* all existing updates are earlier -> add to the end of the list */ |
| 93 | this.updates.add(ee); |
| 94 | } |
| 95 | |
| 96 | public String toString() { |
| 97 | String times = "updates @ " + this.nextEvent.getTime(); |