/** Title: cloudsim toolkit * Description: cloudsim (cloud simulation) Toolkit for modeling and simulation of clouds * Licence: GPL-http://www.gnu.org/copyleft/gpl.html ** copyright (c) 2009-2010, the University of Melbourne, Australia */package Org. cloudid. cloudsim. core; import Java. util. iterator; import Java. util. using list; import Java. util. list; import Java. util. listiterator;/*** this class is a defer queue. The elements are sorted by event time using the sort list structure. * method: * Add event * return iterator * return size * clear queue * This class implements the deferred event queue used by {@ link simulation }. * The event queue uses a linked list to store the events. ** @ authormarcos Dias de assuncao * @ sincecloudsim toolkit 1.0 ** @ seesimulation * @ seesimevent */public class deferredqueue {/** the list. */private final list <simevent> List = new external list <simevent> ();/*** the Max time. * The latest event time **/private double maxtime =-1;/*** the sequence of elements maintained when an event is added to the queue, add * adds a new event to the queue according to the event sequence. adding a new event to the queue * preserves the temporal order of the events. * @ Param newevent the event to be added to the queue. */Public void addevent (simevent newevent) {// The event has to be inserted as the last of all events // with the same event_time (). yes, this matters. // The time when the returned time must occur. Double eventtime = newevent. eventtime (); If (eventtime> = maxtime) {list. add (newevent); maxtime = eventtime; return;} listiterator <simevent> iterator = List. listiterator (); simevent event; // search for while (iterator. hasnext () {event = iterator. next (); If (event. eventtime ()> eventtime) {iterator. previous (); iterator. add (newevent); Return ;}// the queue is an empty list. add (newevent);}/*** returns an iterator to the events in the queue. ** @ return the iterator */Public iterator <simevent> iterator () {return list. iterator ();}/*** returns the size of this event queue. ** @ return the number of events in the queue. */Public int size () {return list. size ();}/*** clears the queue. */Public void clear () {list. clear ();}}