Deferredqueue. Java

Source: Internet
Author: User

/** 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 ();}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.