Ok I have a method:
//_seen is defined as a HashSet earlier
public boolean isTerminal(Node node)
{
if (_seen.contains(node.getState()))
{
return true;
}
else
{
_seen.add(node.getState());
return false;
}
}
What is the nicest way of doing this? It could use a variable to hold _seen.contains
, and return just that, and maybe always add. Or, perhaps I could do:
public boolean isTerminal(Node node)
{
return !_seen.add(node.getState());
}
but is that clear?
isTerminal
seems heavily misleading. \$\endgroup\$