private int nextFreeId(){
  int id=0;
  Set<Integer> ids=solutions.keySet();
  while (ids.contains(id)) {
    id++;
  }
  return id;
}

private int nextFreeId ( ) { int id = 0 ; Set < Integer > ids = solutions . keySet ( ) ; while ( ids . contains ( id ) ) { id ++ ; } return id ; }
returns the next available identifier .
