4.6.0
Freundlich's C++ toolkit
|
A tree data structure.
An fcppt::container::tree::object<T>
is a container modeling a tree of arbitrary arity where nodes are labelled by objects of type T
and its children are of type fcppt::container::tree::object<T>
. Internally, an fcppt::container::tree::object<T>
holds a std::list
of fcppt::container::tree::object<T>
.
Here is an example:
A tree can be used as a range by using begin
and end
to iterate over its children.
There are also traversal classes that can be used to iterate over the whole tree. Here is an example:
Aside from fcppt::container::tree::pre_order pre_order , no other traversals are implemented as of yet.
Classes | |
struct | fcppt::container::tree::is_object< T > |
A meta function testing if the given type is really a tree object. More... | |
struct | fcppt::container::tree::is_object< fcppt::container::tree::object< T > > |
A meta function testing if the given type is really a tree object. More... | |
class | fcppt::container::tree::object< T > |
A tree data structure. More... | |
class | fcppt::container::tree::pre_order< Tree > |
Wraps a tree to make it iterable in a pre-order fashion. More... | |
Functions | |
template<typename T > | |
fcppt::optional::object< fcppt::container::to_iterator_type< T > > | fcppt::container::tree::child_position (T &_parent, T &_child) |
Returns an iterator pointing to the position in the parent's child container where this object resides. | |
template<typename Value > | |
fcppt::container::tree::object< Value >::size_type | fcppt::container::tree::level (fcppt::container::tree::object< Value > const &_tree) |
Calculates the level of a tree. | |
template<typename Tree > | |
fcppt::container::tree::pre_order< Tree > | fcppt::container::tree::make_pre_order (Tree &_tree) |
Creates a pre_order object. | |
template<typename Tree > | |
fcppt::container::tree::to_root< Tree > | fcppt::container::tree::make_to_root (Tree &_tree) |
Creates a to_root object. | |
template<typename Result , typename Value , typename Function > | |
Result | fcppt::container::tree::map (fcppt::container::tree::object< Value > const &_tree, Function const &_function) |
Maps a tree to another tree. | |
template<typename Ch , typename Traits , typename Value > | |
std::basic_ostream< Ch, Traits > & | fcppt::container::tree::operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::container::tree::object< Value > const &_tree) |
Outputs a tree. | |
fcppt::optional::object< fcppt::container::to_iterator_type< T > > fcppt::container::tree::child_position | ( | T & | _parent, |
T & | _child ) |
Returns an iterator pointing to the position in the parent's child container where this object resides.
_parent | The parent tree to search |
_child | The child to search for |
fcppt::container::tree::object< Value >::size_type fcppt::container::tree::level | ( | fcppt::container::tree::object< Value > const & | _tree | ) |
Calculates the level of a tree.
Calculates the level of _tree. A node without a parent has level 0. A node with a parent has the level of its parent plus one.
|
inline |
Creates a pre_order object.
|
inline |
Creates a to_root object.
Result fcppt::container::tree::map | ( | fcppt::container::tree::object< Value > const & | _tree, |
Function const & | _function ) |
Maps a tree to another tree.
Maps _tree to another tree using _function.
std::basic_ostream< Ch, Traits > & fcppt::container::tree::operator<< | ( | std::basic_ostream< Ch, Traits > & | _stream, |
fcppt::container::tree::object< Value > const & | _tree ) |
Outputs a tree.