One thing I think you could do, use a bitset object to record which item is
to be removed. After the loop, loop over the bit set and remove items from
the collection...Just my 3 cents ;-)

Jian

On Wed, Nov 17, 2010 at 1:27 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> Jian,
>
> On 11/17/2010 4:19 PM, jian chen wrote:
> > It seems to me that in java, Iterator can not be modified during the
> > iteration loop. It is not particular to Velocity though.
>
>
> http://download.oracle.com/javase/6/docs/api/java/util/Iterator.html#remove()<http://download.oracle.com/javase/6/docs/api/java/util/Iterator.html#remove%28%29>
>
> You may need to update your interview questions ;)
>
> > If you want to remove elements, maybe during the loop, you could mark the
> > indexes for the items to be removed, then, remove them afterwards?
>
> That's an idea, though much less convenient than calling "remove" on an
> iterator.
>
> Thanks,
> -chris
>
>

Reply via email to