C5 Generics Collection IntervalHeap<T> — getting an IPriorityQueueHandle from a T for Replace or Delete op

StackOverflow https://stackoverflow.com/questions/3010668

  •  26-09-2019
  •  | 
  •  

Question

I'm using the Generics Collection library C5 (server down :-( ) and I have an IntervalHeap(T) and I need to Delete or Replace a T that is not the Max or Min. How do I get an IPriorityQueueHandle from my T? The C5 library source code shows that IPriorityQueueHandle(T) has no methods or properties to implement and the compiler thinks my implementation of IPriorityQueueHandle(T) for my T is acceptable. I try to use a T like this:

q.Replace(t, t);

and the C5 library throws an InvalidCastException because it cannot convert my T to a (Handle).

Was it helpful?

Solution

It looks I can get an IPriorityQueueHandle(t) when I call q.Add(ref t.handle, t) which I can stick into my own field (t.handle) and pull out when I later need to modify t's priority within q with q.Replace(t.handle, t).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top