I am looking for a data structure, optimized for search-operations (in the Java std-lib). I have to iterate over it several times, control every element and delete it in special cases. I have used a HashMap, but I always get following error:
for (Edge e : edges) {
if (special case)
edges.remove(e);
}
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:810)
at java.util.HashMap$KeyIterator.next(HashMap.java:845)
at package.name.TFinder.nN(TFinder.java:83)
at package.name.TFinder.fIT(TFinder.java:56)
at package.name.Main.main(Main.java:215)
From your description, you should be able to use
HashMapfor this. The key is to useiterator.remove()to delete entries: