Set<WithHash> next = new HashSet<WithHash>();
Set<WithHash> mergedRules = new HashSet<WithHash>();
Iterator<WithHash> iterator = rules.iterator();
while(iterator.hasNext()){
WithHash r = iterator.next();
iterator.remove();
for(WithHash r2 : rules){
RuleGraph merged = new RuleMerger(r.getRuleGraph(), r2.getRuleGraph()).merge();
if (merged != null){
next.add(merged.withHash());
mergedRules.add(r);
mergedRules.add(r2);
}
}
if (!mergedRules.contains(r)){
if (!r.getRuleGraph().hasSymmetricalBond() || !list.contains(r.getRuleGraph().getMirror().withHash()))
list.add(r);
}
}
return next;