// Path: src/input/ScheduledUpdatesQueue.java
// public class ScheduledUpdatesQueue implements EventQueue {
// 	/** Time of the event (simulated seconds) */
// 	private ExternalEvent nextEvent;
// 	private List<ExternalEvent> updates;
// 
// 	/**
// 	 * Constructor. Creates an empty update queue.
// 	 */
// 	public ScheduledUpdatesQueue(){
// 		this.nextEvent = new ExternalEvent(Double.MAX_VALUE);
// 		this.updates = new ArrayList<ExternalEvent>();
// 	}
// 
// 	/**
// 	 * Returns the next scheduled event or event with time Double.MAX_VALUE
// 	 * if there aren't any.
// 	 * @return the next scheduled event
// 	 */
// 	public ExternalEvent nextEvent() {
// 		ExternalEvent event = this.nextEvent;
// 
// 		if (this.updates.size() == 0) {
// 			this.nextEvent = new ExternalEvent(Double.MAX_VALUE);
// 		}
// 		else {
// 			this.nextEvent = this.updates.remove(0);
// 		}
// 
// 		return event;
// 	}
// 
// 	/**
// 	 * Returns the next scheduled event's time or Double.MAX_VALUE if there
// 	 * aren't any events left
// 	 * @return the next scheduled event's time
// 	 */
// 	public double nextEventsTime() {
// 		return this.nextEvent.getTime();
// 	}
// 
// 	/**
// 	 * Add a new update request for the given time
// 	 * @param simTime The time when the update should happen
// 	 */
// 	public void addUpdate(double simTime) {
// 		ExternalEvent ee = new ExternalEvent(simTime);
// 
// 		if (ee.compareTo(nextEvent) == 0) { // this event is already next
// 			return;
// 		}
// 		else if (this.nextEvent.getTime() > simTime) { // new nextEvent
// 			putToQueue(this.nextEvent); // put the old nextEvent back to q
// 			this.nextEvent = ee;
// 		}
// 		else { // given event happens later..
// 			putToQueue(ee);
// 		}
// 	}
// 
// 	/**
// 	 * Puts a event to the queue in the right place
// 	 * @param ee The event to put to the queue
// 	 */
// 	private void putToQueue(ExternalEvent ee) {
// 		double eeTime = ee.getTime();
// 
// 		for (int i=0, n=this.updates.size(); i<n; i++) {
// 			double time = updates.get(i).getTime();
// 			if (time == eeTime) {
// 				return; // update with the given time exists -> no need for new
// 			}
// 			else if (eeTime < time) {
// 				this.updates.add(i, ee);
// 				return;
// 			}
// 		}
// 
// 		/* all existing updates are earlier -> add to the end of the list */
// 		this.updates.add(ee);
// 	}
// 
// 	public String toString() {
// 		String times = "updates @ " + this.nextEvent.getTime();
// 
// 		for (ExternalEvent ee : this.updates) {
// 			times += ", " + ee.getTime();
// 		}
// 
// 		return times;
// 	}
// }


import input.EventQueue;
import input.ExternalEvent;
import input.ScheduledUpdatesQueue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
			simClock.setTime(this.nextQueueEventTime);
			ExternalEvent ee = this.nextEventQueue.nextEvent();
			ee.processEvent(this);
			updateHosts(); // update all hosts after every event
			setNextEventQueue();
		}

		moveHosts(this.updateInterval);
		simClock.setTime(runUntil);

		updateHosts();

		/* inform all update listeners */
		for (UpdateListener ul : this.updateListeners) {
			ul.updated(this.hosts);
		}
		
	}

	/**
	 * Updates all hosts (calls update for every one of them). If update
	 * order randomizing is on (updateOrder array is defined), the calls
	 * are made in random order.
	 */
	private void updateHosts() {
		if (this.updateOrder == null) { // randomizing is off
			for (int i=0, n = hosts.size();i < n; i++) {
				if (this.isCancelled) {
					break;
				}
// Path: src/input/ScheduledUpdatesQueue.java
// public class ScheduledUpdatesQueue implements EventQueue {
// 	/** Time of the event (simulated seconds) */
// 	private ExternalEvent nextEvent;
// 	private List<ExternalEvent> updates;
// 
// 	/**
// 	 * Constructor. Creates an empty update queue.
// 	 */
// 	public ScheduledUpdatesQueue(){
// 		this.nextEvent = new ExternalEvent(Double.MAX_VALUE);
// 		this.updates = new ArrayList<ExternalEvent>();
// 	}
// 
// 	/**
// 	 * Returns the next scheduled event or event with time Double.MAX_VALUE
// 	 * if there aren't any.
// 	 * @return the next scheduled event
// 	 */
// 	public ExternalEvent nextEvent() {
// 		ExternalEvent event = this.nextEvent;
// 
// 		if (this.updates.size() == 0) {
// 			this.nextEvent = new ExternalEvent(Double.MAX_VALUE);
// 		}
// 		else {
// 			this.nextEvent = this.updates.remove(0);
// 		}
// 
// 		return event;
// 	}
// 
// 	/**
// 	 * Returns the next scheduled event's time or Double.MAX_VALUE if there
// 	 * aren't any events left
// 	 * @return the next scheduled event's time
// 	 */
// 	public double nextEventsTime() {
// 		return this.nextEvent.getTime();
// 	}
// 
// 	/**
// 	 * Add a new update request for the given time
// 	 * @param simTime The time when the update should happen
// 	 */
// 	public void addUpdate(double simTime) {
// 		ExternalEvent ee = new ExternalEvent(simTime);
// 
// 		if (ee.compareTo(nextEvent) == 0) { // this event is already next
// 			return;
// 		}
// 		else if (this.nextEvent.getTime() > simTime) { // new nextEvent
// 			putToQueue(this.nextEvent); // put the old nextEvent back to q
// 			this.nextEvent = ee;
// 		}
// 		else { // given event happens later..
// 			putToQueue(ee);
// 		}
// 	}
// 
// 	/**
// 	 * Puts a event to the queue in the right place
// 	 * @param ee The event to put to the queue
// 	 */
// 	private void putToQueue(ExternalEvent ee) {
// 		double eeTime = ee.getTime();
// 
// 		for (int i=0, n=this.updates.size(); i<n; i++) {
// 			double time = updates.get(i).getTime();
// 			if (time == eeTime) {
// 				return; // update with the given time exists -> no need for new
// 			}
// 			else if (eeTime < time) {
// 				this.updates.add(i, ee);
// 				return;
// 			}
// 		}
// 
// 		/* all existing updates are earlier -> add to the end of the list */
// 		this.updates.add(ee);
// 	}
// 
// 	public String toString() {
// 		String times = "updates @ " + this.nextEvent.getTime();
// 
// 		for (ExternalEvent ee : this.updates) {
// 			times += ", " + ee.getTime();
// 		}
// 
// 		return times;
// 	}
// }


// Path: src/core/World.java
import input.EventQueue;
import input.ExternalEvent;
import input.ScheduledUpdatesQueue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

			simClock.setTime(this.nextQueueEventTime);
			ExternalEvent ee = this.nextEventQueue.nextEvent();
			ee.processEvent(this);
			updateHosts(); // update all hosts after every event
			setNextEventQueue();
		}

		moveHosts(this.updateInterval);
		simClock.setTime(runUntil);

		updateHosts();

		/* inform all update listeners */
		for (UpdateListener ul : this.updateListeners) {
			ul.updated(this.hosts);
		}
		
	}

	/**
	 * Updates all hosts (calls update for every one of them). If update
	 * order randomizing is on (updateOrder array is defined), the calls
	 * are made in random order.
	 */
	private void updateHosts() {
		if (this.updateOrder == null) { // randomizing is off
			for (int i=0, n = hosts.size();i < n; i++) {
				if (this.isCancelled) {
					break;
				}
				hosts.get(i).update(simulateConnections);