fix: priority queue losing order on item removal or reversed inserting - #3404
IXLLEGACYIXL wants to merge 2 commits into
Conversation
|
Doesn't work in all cases: Issue #3398 explains the real problem. When |
ok so the current improvements fixes the regression that the old tests pass i add this case as well |
|
🤖 Draft PR — automatic CI is skipped to save runner minutes.
|
|
ive added now your test and it passes to decide if order is broken up or downwards on removal |
There was a problem hiding this comment.
PriorityNodeQueue<T>.Remove has the same bug.
It needs the same "move up if smaller than parent" step.
Please add tests in TestPriorityLinkedQueue too.
Remove and Dequeue now have the same sift-down loop.
Private SiftUp/SiftDown helpers would remove the copy (and maybe make the PriorityNodeQueue fix simple).
| } | ||
|
|
||
| [Fact] | ||
| public void TestRemovalOnBubbleDownPreservesOrder() |
There was a problem hiding this comment.
Nit: this test RemovalOnBubbleUp not Down
| CheckPriorityQueue(priorityQueue); | ||
| } | ||
|
|
||
| private static void CheckPriorityQueue(PriorityQueue<int> priorityQueue) |
There was a problem hiding this comment.
CheckPriorityQueue only checks order. If Remove deleted the wrong item, the tests would still pass.
Could the new tests compare the drained values with the expected sorted list?
PR Details
PriorityQueue loses order on Remove/Reverse Inserting
Related Issue
fix #3398
Types of changes
internal bug fix
Checklist
i was able to run around 4445 tests but it was stuck on bepu so few are missing, but the list queue tests pass now, also the old ones