Closed micampbell closed 3 years ago
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.
Good catch! I forgot to remove this restriction when I added the Comparer
constructors. This is fixed in v5.1.0
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 useComparer<TPriority>.Default
but what if I have only intend to use IComparer (instead of IComparable) and theTPriority
object cannot inherit fromIComparable<>
? for example, I want to write something like:var priorityQueue = new SimplePriorityQueue<int, Vertex>(new VertexSorter());
whereVertexSorter
inherits fromIComparer<Vertex>', and not change the class
Vertexto inherit from
IComparableI'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.