private void eliminateDuplicates( LinkedList list, Vector states) { for( int j = 0; j < states.size(); j++ ) { Node temp = (Node) states.elementAt( j ); Iterator it = list.listIterator(); while (it.hasNext()) { Node n = (Node) it.next(); if (n.state.equals(temp.state)) { // found the state in the list if (n.heuristic < temp.heuristic) { // what's already in the list is better than the one // in states, so don't need that one. states.removeElementAt(j); break; } else { // the new state is better than the one on the list, // so can get rid of the one on the list it.remove(); break; } } } }