I need to filter a List (java.util.list). I.e. there is a list of people, and each person has a type assigned. How could we filter it, so recipient method would still be able to add/remove from the list, but all iterators and get()'s would act just as if there are only people with type X in it.
That's a bit problematic, because the code I give list to, also updates it. And I need those updates synchronized with original list. Here is my code:
I have run into some problems with this approach: sometimes I start getting ConcurrentModificationException. When removing records I have to use iterator's remove. Maybe there is an easy way, I missed somehow?
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.