velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Barbara Baughman <baugh...@utdallas.edu>
Subject Re: Mutating a collection
Date Wed, 17 Nov 2010 21:25:40 GMT
Or put a duplicate of the collection in the context with a different reference name.  During
the loop, you can remove the item from the duplicate because you aren't affecting the Iterator
of the original.  Then work with the modified duplicate.

Barbara Baughman
Systems Analyst
X2157

On 11/17/10 15:19, jian chen wrote:
> Hi Chris,
>
> It seems to me that in java, Iterator can not be modified during the
> iteration loop. It is not particular to Velocity though.
>
> 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?
>
> Cheers,
>
> Jian
> http://www.jiansnet.com/search?q=computer+science+interview+questions
>
> On Wed, Nov 17, 2010 at 1:15 PM, Christopher Schultz<
> chris@christopherschultz.net>  wrote:
>
>> All,
>>
>> I'd like to mutate a collection during template evaluation --
>> essentially, I'd like to call Iterator.remove() during a loop. Is that
>> possible? Does Velocity expose an Iterator or anything like that to the
>> template?
>>
>> Or, am I forced to iterate over one collection and add to another one?
>>
>> For that matter, is there a convenient way of creating an empty
>> ArrayList or something similar?
>>
>> Thanks,
>> -chris
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message