OK, that is basically what I thought. What I want to do is iterate over the collection and, under certain circumstances, remove some keys as I find them. So, my algorithm is something like this:
Form key = JFormMap.nextKey(map)
Form nKey
while key
nkey = JFormMap.nextKey(map, key)
if readyToRemove(key)
JFormMap.removeKey(map, key)
endif
key = nKey
endwhile
Based on your reply, I think this algorithm will work as expected. That is, every element should be iterated over, and the ones I want to remove will be removed. Do you agree?
I am also interested in what would happen if another thread added an element to the map while I am iterating over it. From your reply, I assume that, if it is sorted to a position before key (and possibly if it is just before nKey), it will not be iterated over. But, if it is sorted to a position after them, the algorithm will reach it. Is this correct?
One last question: am I correct that the order that elements are iterated over corresponds to their index, so that JFormMap.getNthKey(2) is the third element (indexing from 0) that I will reach using JFormMap.nextKey()?
Thanks again for your help!