Class DeferredQueue

java.lang.Object
org.cloudsimplus.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 the time of a new event is usually equal or higher than the previous event in regular simulations, this class 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
    • iterator

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

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

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

      public boolean isEmpty()
      Description copied from interface: EventQueue
      Returns true if the queue is empty, false otherwise.
      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 given events from the queue.
      Parameters:
      events - the events to be removed
      Returns:
      true if successful; false otherwise
    • removeIf

      public boolean removeIf(Predicate<SimEvent> predicate)
      Removes events that match a given Predicate.
      Parameters:
      predicate - the predicate to match
      Returns:
      true if any elements were removed; false otherwise
    • clear

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

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