开发者

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

开发者 https://www.devze.com 2023-01-03 10:17 出处:网络
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 IPriorityQ

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).


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消