Skip to content

DeferredQueue inserts the least SimEvent to its end instead of its start #474

Answered by manoelcampos
VVsxmja asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @VVsxmja, sorry for the delay.
This class DeferredQueue was inherited from CloudSim. I think that in issue #206 I renamed it to SortedQueue but probably decided to keep the old name in following commits.

Anyway, since it uses a List to store the events and almost all the time each new event will have a time higher than the previous event, those events are added to the end of the list with eventList.add(newEvent). This way the order is expected to be [1.0, 2.0, 3.0, 4.0].

If a Stack was used, then each new event (usually with a time higher than the previous one) would be added to the top of the stack, so that we get a reverse order.

If you have any further comments, please let me know.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by manoelcampos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #465 on October 20, 2023 17:55.