雲端運算模擬工具中文注釋FutureQueue.java

來源:互聯網
上載者: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.cloudbus.cloudsim.core;import java.util.Collection;import java.util.Iterator;import java.util.SortedSet;import java.util.TreeSet;/** * 儲存未來會被執行的event,資料結構採用treeSet * 方法總結: * 排入佇列 * 排入佇列首 * 清除隊列中元素 * This class implements the future event queue used by {@link Simulation}. * The event queue uses a {@link TreeSet} in order to store the events. * * @authorMarcos Dias de Assuncao * @sinceCloudSim Toolkit 1.0 * * @see Simulation * @see java.util.TreeSet */public class FutureQueue {/** The sorted set. */private final SortedSet<SimEvent> sortedSet = new TreeSet<SimEvent>();/** The serial. */private long serial = 0;/** * Add a new event to the queue. Adding a new event to the queue * preserves the temporal order of the events in the queue. * * @param newEvent The event to be put in the queue. */public void addEvent(SimEvent newEvent) {//?serial什麼意思newEvent.setSerial(serial++);//自動排序sortedSet.add(newEvent);}/** * Add a new event to the head of the queue.  * * @param newEvent The event to be put in the queue. */public void addEventFirst(SimEvent newEvent) {//與addevent只有這句不同.serial可能是優先權的意思newEvent.setSerial(0);sortedSet.add(newEvent);}/** * Returns an iterator to the queue. * * @return the iterator */public Iterator<SimEvent> iterator() {return sortedSet.iterator();}/** * Returns the size of this event queue. * * @return the size */public int size() {return sortedSet.size();}/** * Removes the event from the queue. * * @param event the event * * @return true, if successful */public boolean remove(SimEvent event) {return sortedSet.remove(event);}/** * Removes all the events from the queue. * * @param events the events * * @return true, if successful */public boolean removeAll(Collection<SimEvent> events) {return sortedSet.removeAll(events);}/** * Clears the queue. */public void clear(){sortedSet.clear();}}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.