|
Boost : |
From: christopher diggins (cdiggins_at_[hidden])
Date: 2005-02-24 13:44:34
----- Original Message -----
From: "Joao Abecasis" <jpabecasis_at_[hidden]>
> Thorsten Ottosen wrote:
>> I'm not to keen on the idea that iterators are parameterized with an
>> iteration policy.
>> It would be more natural just to have
>>
>> tree_t::inorder_iterator i = tr.inorder_begin();
>> tree_t::preorder_iterator i2 = tr.preorder_begin();
>
> I think a generic tree should only be required to provide basic tree
> traversal iterators like from parent to child and among children or
> siblings.
>
> From the basic iterators other types of traversal are possible. In my
> unfinished tree library (see my other post) the same effect would be
> accomplished with:
>
> inorder_iterator<tree_t::tree_iterator> i = tr.root();
> preorder_iterator<tree_t::tree_iterator> i2 = tr.root();
>
> This keeps the interface and the implementation of the tree cleaner. One
> could also use BGL algorithms here if the tree exposes a Graph interface.
Why not have just one kind of iterator:
template<typename T, typename Iter_T>
struct tree {
typedef typename Iter_T iterator;
iterator preorder_begin();
iterator postorder_end();
iterator inorder_end();
iterator end();
iterator begin(); // calls inorder_begin()
}
?
Christopher Diggins
Object Oriented Template Library (OOTL)
http://www.ootl.org
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk