❔ Exists a node in priority queue or not (O(1)) with value type nodes
In reference types, it is OK.
There is an array of a struct type(Element) and I would like to swap some elements in it. Each element keeps its index as well.
Outside, an element of that array has been stored in a variable for example. Because it is value type, when swapping elements of the array and update index field, it does not reflect it, what is your idea?
swap element(10) with element(5) and update index field inside.
Now, index in el is not updated because it is value type
My original situation is priority queue implemented for value types.
I keep index of nodes inside nodes. When the positions of those nodes change (heapify up/down), indices change.
Now, suppose I have kept a node of the priority queue in a variable. So, the index is wrong and obsolete
I want to know if a node exists in a priority queue or not (O(1)) but with value type nodes not ref types and then update the priority value for that node
3 Replies
Because it is value type, when swapping elements of the array and update index field, it does not reflect it, what is your idea?wdym by this
what is your idea?modify the
Index
before swapping the elementsWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.