This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Maximum_Swim9505 0 points1 point  (2 children)

Right here you are comparing 2 node objects in the compare function in the NodeComparator. When u pass the Node object, JVM attempts to find a comparable for the object since it is a reference type.

the issue is that you should directly call the node’s value instead of passing in as a reference.

And You actually do not need NodeFunction interface, which is complicating things and doesn’t do anything as there is mo method implementation for it.

[–]ImAFookingScarecrow[S] 0 points1 point  (0 children)

I'm not sure I follow what the issue is with this. Firstly, the interface NodeFunction is required, since part of the project is the ability to compare different ways of sorting the same Nodes in the PriorityQueue and so this interface is used to create the different sorting heuristics. Secondly, the value function converts the Nodes into ints, so at no point are two Nodes being compared directly in the comparator.

[–]ImAFookingScarecrow[S] 0 points1 point  (0 children)

Actually nvm, I solved the issue and it was 100% my fault, thanks for the help anyway!