This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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?