From: Brian McNamara (lorgon_at_[hidden])
Date: 2004-02-27 18:10:50
On Thu, Feb 26, 2004 at 03:13:11PM -0500, Brian McNamara wrote:
> On Thu, Feb 26, 2004 at 02:39:40PM +0200, Peter Dimov wrote:
> > and obvious question #2 is why I should copy the tree
> > into a list at all, when I could've just flattened it into a sequence with
> > iterators. To be fair, you do point that out yourself.
> Good point; I was just keeping the example simple.
> (In fact, when you use fcpp::lists with lazy evaluation, lists
> effectively become input iterators. It would be interesting to
> implement inorder-iterators for this tree both with and without FC++.
> Hmm. How easy/hard would it be to build bidirectional iterators for a
> tree like this? I've never tried. If you have the time to cook some up
> (using Boost), I would enjoy seeing them, and comparing them to whatever I
> could cook up with FC++.)
Hmm, I wrote a reply to this, but never saw it and fear it is lost
forever in the ether.
The summary was
- the Tree data structure I wrote is not amenable to bidirectional
iterators (no uplinks)
- it is reasonable to write forward iterators instead
- you can implement forward iterators "by hand", or you can use a
variation of fold_tree, FC++ lists, and lazy evaluation to get
iterators with the same behavior (maybe with less code)
-- -Brian McNamara (lorgon_at_[hidden])
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk