An iterator works fine if you use the iterator's add and remove methods (iterator.add). I discovered that after running into the ConcurrentModificationException and doing some more research. There's another problem, however, because the iterator's cursor is always in between elements in the collection. When you add a new object to the collection, it gets placed behind the cursor. I have to keep track of how many things I've added and move the iterator back to look at them. I'm thinking I'll switch back to a queue at this point. The only reason I wanted to try the ArrayList in the first place was to see if it was somehow more accurate with detecting duplicates in the collection.
I've tried using a LinkedList, an ArrayList, and now a hash set to hold the blocks I've already looked at. In each case, I just used the collection's #contains method to see if the BlockPos is already in the list. Looks like the same thing you're doing here:
if (!checked.contains(toAdd))
My code is currently part of a private BitBucket repository. I didn't want it to be public at first, because I was embarrassed. I was going to post some of my code here , but it looks like it isn't possible to do spoilers or code blocks in topic replies. Unless I'm missing something?
Come to think of it, how do you do that monospace font in replies? All I see are bold, italic, and underline.
By the way, I loved your idea of using a list of BlockPos offsets and iterating through that to scan for log blocks. I tried that in my code, and it's so much cleaner than what I was doing before, which was basically a giant block of code with a million BlockPos.up().north().east() references and the like.