J
jpprost
Hi,
I can't find an implementation of Collection which would let me legally
add new elements to the very list I iterate on. Let me re-phrase: I
want to iterate on an array/list (or whatever structure which is
Collection-compatible) and in the meantime add new elements to this
list (say at the end), so that they are taken into account in the
iteration process. It's important to emphasize that I only need to add
new elements--no removal is required.
- A SynchronizedList doesn't help here, since my application is
mono-thread--and anyway even when faking a synchronized section I still
get a ConcurrentModificationException.
- I thought a ListIterator with a LinkedList would be the solution, but
no: I still get the same exception--though in theory I don't see the
problem: I should be allowed to add new elements at the end of a linked
list on which I iterate, shouldn't I?...
Do I really have to implement something myself, or should I have a
better look somewhere?
Cheers,
--
Jean-Philippe Prost [E6A 341, x9542]
Centre for Language Technology
Macquarie University ~ Sydney, Australia
<http://www.ics.mq.edu.au/~jpprost/>
_______________________________________________
I can't find an implementation of Collection which would let me legally
add new elements to the very list I iterate on. Let me re-phrase: I
want to iterate on an array/list (or whatever structure which is
Collection-compatible) and in the meantime add new elements to this
list (say at the end), so that they are taken into account in the
iteration process. It's important to emphasize that I only need to add
new elements--no removal is required.
- A SynchronizedList doesn't help here, since my application is
mono-thread--and anyway even when faking a synchronized section I still
get a ConcurrentModificationException.
- I thought a ListIterator with a LinkedList would be the solution, but
no: I still get the same exception--though in theory I don't see the
problem: I should be allowed to add new elements at the end of a linked
list on which I iterate, shouldn't I?...
Do I really have to implement something myself, or should I have a
better look somewhere?
Cheers,
--
Jean-Philippe Prost [E6A 341, x9542]
Centre for Language Technology
Macquarie University ~ Sydney, Australia
<http://www.ics.mq.edu.au/~jpprost/>
_______________________________________________