首页 > 代码库 > CloudSim源代码之FutureQueue
CloudSim源代码之FutureQueue
package org.cloudbus.cloudsim.core;import java.util.Collection;import java.util.Iterator;import java.util.SortedSet;import java.util.TreeSet;/**执行未来事件队列 * This class implements the future event queue. * The event queue uses a TreeSet in order to store the events. */ public class FutureQueue { /** The sorted set.分类集合 */ private final SortedSet<SimEvent> sortedSet = new TreeSet<SimEvent>(); 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) { newEvent.setSerial(serial++); 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(); }}
CloudSim源代码之FutureQueue
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。