You are trying to add a Node<T> to a collection that holds "something that is a subclass of Node<T>". What if your fringe happens to be an ArrayList<SubNode<T>>? Clearly, you are not allowed to add some Node<T> when it expects a SubNode<T>. One solution is to remove the upper bound on your fringe: simply make it a Collection<Node<T>>.
Joined: Aug 04, 2009
I've not mentioned that the code was as you told to be a Collection<Node<T>>. But on design progress I needed a subclass of Node<T> called HeuristicNode<T>. Somewhere else I've gonna need to add that subclass object to fringe. That's why the fringe must be as it is declared.
Can imagine any other solution!?
Stephan van Hulst
Joined: Sep 20, 2010
I think the neatest way is to probably just make it a Collection<Node<T>> and then simply add HeuristicNode<T> to it when you need to. Then when you retrieve nodes, simply check whether the node is a HeuristicNode: