I have to store a close list for this I defined a Map –
Map<Node, Boolean> closeList = new HashMap<Node, Boolean>()
now for checking whether a node is exist in this map I use –
boolean binExists = closeList .containsKey(node)
seems that the value-boolean of the map is unnecessary .
Have you any better idea for this check using HashMap mode (O(1)) ?
A HashSet seems to be exactly what you need.
Even though using a
Set<Node>looks better than using aMap<Node, Boolean>,java.util.HashSetis using aHashMapinternally in it’s implementation. If you need an implementation that uses less memory, you could for instance have a look at this implementation.