Others have mentioned the correct solution without actually spelling it out. So here it is:
Iterator<Map.Entry<String, Integer>> iterator =
group0.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, Integer> entry = iterator.next();
// determine where to assign 'entry'
iEntryGroup = hasBeenAccusedByGroup(entry.getKey());
if (iEntryGroup == 1) {
assign(entry.getKey(), entry.getValue(), 2);
} else {
assign(entry.getKey(), entry.getValue(), 1);
}
// I don't know under which conditions you want to remove the entry
// but here's how you do it
iterator.remove();
}
Also, if you want to safely change the map in your assign function, you need to pass in the iterator (of which you can only use the remove function and only once) or the entry to change the value.