Class DeferredQueue
java.lang.Object
org.cloudbus.cloudsim.core.events.DeferredQueue
- All Implemented Interfaces:
EventQueue
An
EventQueue
that orders SimEvent
s 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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new event to the queue, preserving the temporal order of the events.void
clear()
Clears the queue removing all elements.first()
Gets the first element of the queue.int
Keeps track of the total number of events added to the middle of the queue, just for debug purpose.int
Keeps track of the total number of events added to the tail of the queue, just for debug purpose.int
Keeps track of the maximum number of events added to the queue, just for debug purpose.boolean
isEmpty()
Checks if the queue is empty.iterator()
Returns an iterator to the events in the queue.boolean
Removes the event from the queue.boolean
removeAll
(Collection<SimEvent> events) Removes all the events from the queue.boolean
int
size()
Returns the size of this event queue.stream()
Returns a stream to the elements into the queue.
-
Constructor Details
-
DeferredQueue
public DeferredQueue()
-
-
Method Details
-
addEvent
Adds a new event to the queue, preserving the temporal order of the events.- Specified by:
addEvent
in interfaceEventQueue
- Parameters:
newEvent
- the event to be added to the queue.
-
iterator
Returns an iterator to the events in the queue.- Specified by:
iterator
in interfaceEventQueue
- Returns:
- the iterator
-
stream
Returns a stream to the elements into the queue.- Specified by:
stream
in interfaceEventQueue
- Returns:
- the stream
-
size
public int size()Returns the size of this event queue.- Specified by:
size
in interfaceEventQueue
- 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 interfaceEventQueue
- Returns:
- true if the queue is empty, false otherwise
-
remove
Removes the event from the queue.- Parameters:
event
- the event- Returns:
- true if successful; false otherwise
-
removeAll
Removes all the events from the queue.- Parameters:
events
- the events- Returns:
- true if successful; false otherwise
-
removeIf
-
clear
public void clear()Clears the queue removing all elements. -
first
Description copied from interface:EventQueue
Gets the first element of the queue.- Specified by:
first
in interfaceEventQueue
- 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.
-