Details
-
Improvement
-
Status: Closed
-
Trivial
-
Resolution: Fixed
-
None
-
None
-
None
-
New
Description
Currently the priority queue implementation always replaces the top (minimum) element, even if it is equal to the provided argument. This seems redundant. I've modified the condition and polished a few other minor things (unnecessary cast, size modification even if add throws AIOOB).
Separately from the above, it is quite weird that a pq of size zero is allowed (and actually used!). The code is incorrect in this case, allowing add() to proceed and top() to return the added value. I understand it's a heavily used data structure but perhaps we should at least add an assertion to add() checking for zero-size?
Attachments
Issue Links
- links to