-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comparing with null? #11
Comments
I created a test setup showing this:
The comparer orders files according to MyDate. I am a little bit uncertain if the Remove |
For reference, the above gives this exception:
At his line in FooComparer:
where x is null. |
Hello |
If I enable the commented lines in the comparer that handle the null values, I get null value instead of Foo objects when calling Peek. Is my comparer faulty with the commented lines uncommented? |
Your comparer seems fine. |
I am not familiar with a heap based priority queue. I won't be able to help debug and fix it, sorry. I checked the internal _heap and saw that element 0 was null while element 1 and 2 were Foo objects. The null was placed there upon the Remove that triggered the null exception in FooCompare. So I would guess the Remove method to have the flaw. |
It seems so. I'm transferring this repository to a friend, since I don't have time to work on it. |
@heinrich-ulbricht I think I went another way. I don't know the state of this issue. |
I have implemented my own IComparer to be used with the priority queue, but I am wondering if it is a bug that my comparer occasionally gets called with null reference instead of a valid object?
I am actually not certain how I should handle null values here as I only expected to have objects from the queue passed.
The null to the comparer happens when I call Remove on the queue (with a non-null value).
The item I try to remove is NOT on the queue. Should this result in null-values being passed to the comparer?
The text was updated successfully, but these errors were encountered: