Closed phildo77 closed 5 years ago
[EDIT] Ah, I was wrong! queue.Contains(node)
works correctly on an empty queue.
I tried implementing your suggestion, but it led to an unacceptable speed regression (3% if I set the QueueIndex
to 0, 20% (!!) if I check bounds in Contains()
).
In the end, I've decided to add a ResetNode()
method. Nodes that are added to a queue belong to that queue forever, until oldQueue.ResetNode(node)
is called. Attempting to call Enqueue
or Contains
on the wrong queue for a node will lead to an exception in Debug mode, undefined behavior in Release. None of this applies to SimplePriorityQueue
, which still behaves as you'd expect.
Added in v4.2.0
FYI - Reusing nodes (from one queue to another) breaks the debug check for QueueIndex in Contains(node).
Maybe change the QueueIndex back to zero on a Dequeue or possibly change to 0 in debug check before Contains?
EDIT: Sorry - this is for FastPriorityQueue