Write a tree structure with different view-based traversals.
More...
|
| namespace | test_5_10 |
| | Tests functionality from Exercise 5-10.
|
| |
| namespace | exercise_5_10 |
| | Encapsulate solution for Exercise 5-10.
|
| |
|
| struct | boost::mpl::end_impl< exercise_5_10::inorder_view_tag > |
| | Simply returns inorder_view_iterator_end. More...
|
| |
| struct | boost::mpl::begin_impl< exercise_5_10::inorder_view_tag > |
| | The begin algorithm needs to traverse to the leftmost element, creating iterators along the way. More...
|
| |
| struct | boost::mpl::next< exercise_5_10::inorder_view_iterator< Cur, Parent, VisitCount > > |
| | In-order traversal. More...
|
| |
| struct | boost::mpl::next< exercise_5_10::inorder_view_iterator< Cur, Parent, 0 > > |
| | Visiting a leaf for the first time: present it as the "next" item. More...
|
| |
| struct | boost::mpl::next< exercise_5_10::inorder_view_iterator< chapter5::tree< Cur, L, R >, Parent, VisitCount > > |
| | This is an error – Visit count must not be [0,3]. More...
|
| |
| struct | boost::mpl::next< exercise_5_10::inorder_view_iterator< chapter5::tree< Cur, L, R >, Parent, 0 > > |
| | We've never visited this item, so we should start by going left. More...
|
| |
| struct | boost::mpl::next< exercise_5_10::inorder_view_iterator< chapter5::tree< Cur, void_, R >, Parent, 0 > > |
| | Same as above, but L node is empty, so go back up... More...
|
| |
| struct | boost::mpl::next< exercise_5_10::inorder_view_iterator< chapter5::tree< Cur, L, R >, Parent, 1 > > |
| | Seen this node once, so we should present it as the "next" item. More...
|
| |
| struct | boost::mpl::next< exercise_5_10::inorder_view_iterator< chapter5::tree< Cur, L, R >, Parent, 2 > > |
| | Visited this node twice already, so the only place to go is right. More...
|
| |
| struct | boost::mpl::next< exercise_5_10::inorder_view_iterator< chapter5::tree< Cur, L, void_ >, Parent, 2 > > |
| | Same as above, but R node is empty, so go back up... More...
|
| |
| struct | boost::mpl::next< exercise_5_10::inorder_view_iterator< chapter5::tree< Cur, L, R >, Parent, 3 > > |
| | Go back up the tree. If we reach "end" as the parent, we've fully traversed the tree. More...
|
| |
| struct | boost::mpl::deref< exercise_5_10::inorder_view_iterator< Cur, Parent, VisitCount > > |
| | This specialization is only for leaf nodes. Grab it directly from the iterator. More...
|
| |
| struct | boost::mpl::deref< exercise_5_10::inorder_view_iterator< chapter5::tree< Cur, L, R >, Parent, VisitCount > > |
| | Grab the first value from the subtree contained in the iterator. More...
|
| |
Write a tree structure with different view-based traversals.
5-10* Write a tree class template for composing compile-time binary tree
data structures:
typedef tree< // double
double // / \
, tree<void*,int,long> // void* char
, char // / \
> tree_seq; // int long
Implement iterators for pre-order, in-order, and post-order traversal
of the tree elements:
BOOST_STATIC_ASSERT(( mpl::equal<
preorder_view<tree_seq>
, mpl::vector<double,void*,int,long,char>
, boost::is_same<_1,_2>
>::value ));
BOOST_STATIC_ASSERT(( mpl::equal<
inorder_view<tree_seq>
, mpl::vector<int,void*,long,double,char>
, boost::is_same<_1,_2>
>::value ));
BOOST_STATIC_ASSERT(( mpl::equal<
postorder_view<tree_seq>
, mpl::vector<int,long,void*,char,double>
, boost::is_same<_1,_2>
>::value ));
- Todo:
Pre-order tree traversal!
Post-order tree traversal!