[jdom-interest] Removing elements from an Iterator...

Jason Hunter jhunter at collab.net
Fri Jan 5 12:11:34 PST 2001


> (new to this list)

Welcome!

> I'm currently trying to remove a bunch of elements that satisfy
> whatever test... my best way seems to iterate through the elements
> with getChildren().iterator() then when an element is targetted...
> I'm removing it with the remove() method.
> 
> Turns out the getChildren() object is an org.jdom.PartialList which
> seems to not care at all about iterator it can give me, which means
> it will not relay any operation on this iterator, in particular the
> remove() method.

Yep, the iterator returned by PartialList is known to have problems (as
you can see in the TODO.txt file).  Jools is working on a much improved
design that should solve these known issues.

> Does anyone have more comment on this PartialList class so that I
> could understand it a bit better and probably implement this iterator
> ?? It seems to have hidden "backing" list which is, surprisingly, not
> made using a kind of map but is probably filled by hand.

Personally I'm not going to hack together a new iterator impl because
it's going to be thrown away before long.  If you only need to call
remove() though, it probably wouldn't be too hard to rewrite PartialList
to return your own iterator impl as a short term hack, one where
remove() does the thing you need.

-jh-



More information about the jdom-interest mailing list