Class DeferredQueue

java.lang.Object
org.cloudbus.cloudsim.core.events.DeferredQueue
All Implemented Interfaces:
EventQueue

public class DeferredQueue extends Object implements EventQueue
An EventQueue that orders SimEvents based on their time attribute. Since a new event's time is usually equal or higher than the previous event in regular simulations, this classes uses a LinkedList instead of a SortedSet such as TreeSet because the LinkedList provides constant O(1) complexity to add elements to the end.
Since:
CloudSim Plus 4.4.2
Author:
Marcos Dias de Assuncao, Manoel Campos da Silva Filho
  • Constructor Details

    • DeferredQueue

      public DeferredQueue()
  • Method Details

    • addEvent

      public void addEvent(SimEvent newEvent)
      Adds a new event to the queue, preserving the temporal order of the events.
      Specified by:
      addEvent in interface EventQueue
      Parameters:
      newEvent - the event to be added to the queue.
    • iterator

      public Iterator<SimEvent> iterator()
      Returns an iterator to the events in the queue.
      Specified by:
      iterator in interface EventQueue
      Returns:
      the iterator
    • stream

      public Stream<SimEvent> stream()
      Returns a stream to the elements into the queue.
      Specified by:
      stream in interface EventQueue
      Returns:
      the stream
    • size

      public int size()
      Returns the size of this event queue.
      Specified by:
      size in interface EventQueue
      Returns:
      the number of events in the queue.
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: EventQueue
      Checks if the queue is empty.
      Specified by:
      isEmpty in interface EventQueue
      Returns:
      true if the queue is empty, false otherwise
    • remove

      public boolean remove(SimEvent event)
      Removes the event from the queue.
      Parameters:
      event - the event
      Returns:
      true if successful; false otherwise
    • removeAll

      public boolean removeAll(Collection<SimEvent> events)
      Removes all the events from the queue.
      Parameters:
      events - the events
      Returns:
      true if successful; false otherwise
    • removeIf

      public boolean removeIf(Predicate<SimEvent> predicate)
    • clear

      public void clear()
      Clears the queue removing all elements.
    • first

      public SimEvent first() throws NoSuchElementException
      Description copied from interface: EventQueue
      Gets the first element of the queue.
      Specified by:
      first in interface EventQueue
      Returns:
      the first element
      Throws:
      NoSuchElementException - when the queue is empty
    • getAddedToTail

      public int getAddedToTail()
      Keeps track of the total number of events added to the tail of the queue, just for debug purpose.
    • getAddedToMiddle

      public int getAddedToMiddle()
      Keeps track of the total number of events added to the middle of the queue, just for debug purpose.
    • getMaxSize

      public int getMaxSize()
      Keeps track of the maximum number of events added to the queue, just for debug purpose.