2.10.0
Freundlich's C++ toolkit
Classes | Public Types | Public Member Functions
fcppt::container::tree::pre_order< Tree > Class Template Reference

Detailed Description

template<typename Tree>
class fcppt::container::tree::pre_order< Tree >

Wraps a tree to make it iterable in a pre-order fashion.

Internally, this class manages a stack, losely imitating the runtime stack in a recursive implementation.

Example:

> string_tree;
// Create a tree, insert 5 elements below the root
string_tree tree(
FCPPT_TEXT("hello")
);
tree.push_back(
FCPPT_TEXT("foo")
);
tree.push_back(
FCPPT_TEXT("bar")
);
tree.push_back(
FCPPT_TEXT("baz")
);
tree.front().get_unsafe().get().push_back(
FCPPT_TEXT("qux")
);
// Create a traversal and "attach" it to the tree in the ctor
// Then use it like a forward-iterable container!
// This outputs:
//
// hello, foo, qux, bar, baz
for(
string_tree const &item
:
string_tree const
>(
tree
)
)
<< item.value()
<< std::endl;

Classes

class  iterator
 

Public Types

typedef iterator const_iterator
 

Public Member Functions

 pre_order (Tree &_tree)
 Construct a pre-order traversal from a tree (which can be const or nonconst) More...
 
iterator begin () const
 Return an iterator to the first tree in the traversal. More...
 
iterator end () const
 Return a dummy iterator to stop the traversal. More...
 

Member Typedef Documentation

◆ const_iterator

template<typename Tree >
typedef iterator fcppt::container::tree::pre_order< Tree >::const_iterator

Constructor & Destructor Documentation

◆ pre_order()

template<typename Tree >
fcppt::container::tree::pre_order< Tree >::pre_order ( Tree &  _tree)
inlineexplicit

Construct a pre-order traversal from a tree (which can be const or nonconst)

Member Function Documentation

◆ begin()

template<typename Tree >
iterator fcppt::container::tree::pre_order< Tree >::begin ( ) const
inline

Return an iterator to the first tree in the traversal.

◆ end()

template<typename Tree >
iterator fcppt::container::tree::pre_order< Tree >::end ( ) const
inline

Return a dummy iterator to stop the traversal.