You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For using SimplePriorityQueue...As far as I can tell from the implemented constraint, where TPriority : IComparable<TPriority>,
this is based on the fact that some constructors use Comparer<TPriority>.Default
but what if I have only intend to use IComparer (instead of IComparable) and the TPriority object cannot inherit from IComparable<>?
for example, I want to write something like: var priorityQueue = new SimplePriorityQueue<int, Vertex>(new VertexSorter());
where VertexSorter inherits from IComparer<Vertex>', and not change the class Vertexto inherit fromIComparable`.
I'm not sure that the implementation can have it both ways, but I thought I'd pose the question to you. Otherwise, my options are to write a small wrapper class for Vertex or try to remove the restriction from a local version of your awesome library.
The text was updated successfully, but these errors were encountered:
Interestingly, I commented where TPriority : IComparable<TPriority> from SimplePriorityQueue (and related: Generic.., IPriorityQueue, and IFixedSize..) and it compiles and runs just fine with my code. However, I'm not going make a pull request because I'm not clear on the implications of this change.
For using SimplePriorityQueue...As far as I can tell from the implemented constraint,
where TPriority : IComparable<TPriority>
,this is based on the fact that some constructors use
Comparer<TPriority>.Default
but what if I have only intend to use IComparer (instead of IComparable) and the
TPriority
object cannot inherit fromIComparable<>
?for example, I want to write something like:
var priorityQueue = new SimplePriorityQueue<int, Vertex>(new VertexSorter());
where
VertexSorter
inherits fromIComparer<Vertex>', and not change the class
Vertexto inherit from
IComparable`.I'm not sure that the implementation can have it both ways, but I thought I'd pose the question to you. Otherwise, my options are to write a small wrapper class for
Vertex
or try to remove the restriction from a local version of your awesome library.The text was updated successfully, but these errors were encountered: