Ok I have a method://_seen is defined as a HashSet earlierpublic 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?
Sets, Check and add
java
First of all I don't think its a good idea to have a function that does all that tasks Check, Sets and Add.The code should look like this:public boolean isTerminal(Node node){     return _seen.contains(node.getState());}and if you want to add the state/node, you should have a separate methodpublic void addNode(Node node){     if (!isTerminal(node))     {         _seen.add(node.getState());     }}Hope I understood well what you need.Cheers!