码迷,mamicode.com
首页 > 其他好文 > 详细

CloudSim源代码之FutureQueue

时间:2015-01-26 13:32:56      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
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();
    }
}
View Code

 

CloudSim源代码之FutureQueue

标签:

原文地址:http://www.cnblogs.com/Murcielago/p/4249892.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!