commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pwomack <pwom...@papermule.co.uk>
Subject Re: [collections] how to *NEST* (not CHAIN) iterators
Date Thu, 13 Nov 2003 09:39:23 GMT
Stephen Colebourne wrote:
> We have nothing that I can think of that would help. What you need it would
> seem is a variation on the IteratorChain that takes in a collection of
> things that have iterators.

I think I need something that takes an iterator...
that returns things that have iterators.

Essentially, the IteratorChain takes a collection (along
with some very useful parameter overloads).

But one of the claimed benefits of the design
is *avoiding* having to construct collections,
allowing the user to iterate over a "virtual" collection.

What I want to do is add this benefit to IteratorChain
itself.

     BugBear

> 
> Stephen
> 
> ----- Original Message -----
> From: "pwomack" <pwomack@papermule.co.uk>
> To: <commons-user@jakarta.apache.org>
> Sent: Wednesday, November 12, 2003 11:37 AM
> Subject: [collections] how to *NEST* (not CHAIN) iterators
> 
> 
> 
>>Consider the following:
>>
>>Class 'A' contains many 'B's
>>It provides an Iterator() over these 'B's
>>
>>Class 'B' contains many 'C's
>>It provides an Iterator() over these 'C's
>>
>>I would like to add a method to class 'A'
>>that returns an iterator over the 'C's it
>>(indirectly) contains.
>>
>>The obvious way is to use the 'A' level iterator
>>to get all the 'B's, and to add the iterator from
>>each 'B' to a ChainedIterator, whic gives the correct result.
>>
>>However, if A is large, the resulting ChainedIterator
>>has is also large, and potentially time consuming to generate.
>>
>>Essentially we've been forced to build (something like)
>>the list of 'B's which is what the various Iterators in
>>Collections are designed to avoid.
>>
>>I would like (somehow) to iterate over the 'C's directly,
>>by somehow "nesting" (as opposed to chaining) the 2 levels
>>of iteration, but cannot see how.
>>
>>      BugBear (AKA P Womack)
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 



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


Mime
View raw message