43 #include <boost/container/stable_vector.hpp> 44 #include <boost/noncopyable.hpp> 85 template <
typename T>
class Tree 95 template<
typename Vect>
const TreeNode<T>* find(
const Vect& concatenated_values,
bool partial_allowed =
false);
111 void print_impl(std::ostream& os,
const TreeNode<T> *node,
int indent )
const;
119 template <
typename T>
inline 120 std::ostream& operator<<(std::ostream &os, const std::pair<const TreeNode<T>*,
const TreeNode<T>* >& tail_head )
125 if( !head )
return os;
129 array[index++] = head;
131 while( !head || head != tail)
134 array[index++] = head;
136 array[index] =
nullptr;
142 os << array[index]->
value();
144 if( index >0 ) os <<
".";
150 template <
typename T>
inline 153 for (
int i=0; i<indent; i++) os <<
" ";
154 os << node->
value() << std::endl;
158 print_impl(os, &
child, indent+3);
162 template <
typename T>
inline 169 template <
typename T>
inline 179 template <
typename T>
template<
typename Vect>
inline 184 for (
const auto&
value: concatenated_values)
196 if( !found )
return nullptr;
199 if( partial_allowed || node->
children().empty() )
212 #endif // STRINGTREE_H const ChildrenVector & children() const
TreeNode< T > * root()
Mutable pointer to the root of the tree.
Element of the tree. it has a single parent and N >= 0 children.
const TreeNode * parent() const
const TreeNode< T > * croot() const
Constant pointer to the root of the tree.
TreeNode * child(size_t index)
void setValue(const T &value)
const TreeNode * child(size_t index) const
TreeNode(const TreeNode *parent)
const TreeNode< T > * find(const Vect &concatenated_values, bool partial_allowed=false)
friend std::ostream & operator<<(std::ostream &os, const Tree &_this)
TreeNode * addChild(const T &child)
std::unique_ptr< TreeNode< T > > _root
ChildrenVector & children()
std::vector< TreeNode > ChildrenVector
void print_impl(std::ostream &os, const TreeNode< T > *node, int indent) const