wesleyteal
2021-12-21 22:14:55

@wesleyteal has joined the channel


jcoo092
2021-12-21 22:26:03

Question prompted by a discussion elsewhere: If you were using a data structure named ‘PriorityQueue’, would you expect it to maintain FIFO ordering for values with the same priority?


massung
2021-12-21 22:29:45

Yes. But because priority should increase on items over time so it’s not possible to never do because of constant, higher priority items being added. So they really aren’t the same priority internally.


jcoo092
2021-12-21 22:30:52

Ok, if we put aside priority aging, would you expect FIFO behaviour ? :slightly_smiling_face:


soegaard2
2021-12-21 22:51:39

I would expect the behaviour to be documented - but both choices are valid.


jcoo092
2021-12-21 22:52:19

Would not maintaining the ordering mean it isn’t a queue pretty much by definition, though?


soegaard2
2021-12-21 22:52:26

Also, it is trivial to insert (object,counter) instead of just object, if you need it.


soegaard2
2021-12-21 22:54:24

The priority queue needs more space if it needs to store a time counter.


sorawee
2021-12-22 02:12:36

In sorting, this behavior is called stable, fwiw