84 template <
typename T>
class Tree 94 template<
typename Vect>
const TreeNode<T>*
find(
const Vect& concatenated_values,
bool partial_allowed =
false);
108 template <
class Functor>
120 void print_impl(std::ostream& os,
const TreeNode<T> *node,
int indent )
const;
128 template <
typename T>
inline 129 std::ostream& operator<<(std::ostream &os, const std::pair<const TreeNode<T>*,
const TreeNode<T>* >& tail_head )
134 if( !head )
return os;
138 array[index++] = head;
140 while( !head || head != tail)
143 array[index++] = head;
145 array[index] =
nullptr;
151 os << array[index]->
value();
153 if( index >0 ) os <<
".";
159 template <
typename T>
inline 162 for (
int i=0; i<indent; i++) os <<
" ";
163 os << node->
value() << std::endl;
167 print_impl(os, &
child, indent+3);
171 template <
typename T>
inline 178 template <
typename T>
inline 188 template <
typename T>
template<
typename Vect>
inline 193 for (
const auto&
value: concatenated_values)
205 if( !found )
return nullptr;
208 if( partial_allowed || node->
children().empty() )
221 #endif // STRINGTREE_H void visit(Functor &func, const TreeNode< T > *node) const
const TreeNode< T > * find(const Vect &concatenated_values, bool partial_allowed=false)
const TreeNode * child(size_t index) const
#define assert(condition)
friend std::ostream & operator<<(std::ostream &os, const Tree &_this)
void setValue(const T &value)
const ChildrenVector & children() const
ChildrenVector & children()
TreeNode * addChild(const T &child)
const TreeNode< T > * croot() const
Constant pointer to the root of the tree.
TreeNode(const TreeNode *parent)
TreeNode * child(size_t index)
TreeNode< T > * root()
Mutable pointer to the root of the tree.
std::unique_ptr< TreeNode< T > > _root
std::vector< TreeNode > ChildrenVector
void print_impl(std::ostream &os, const TreeNode< T > *node, int indent) const
const TreeNode * parent() const
Element of the tree. it has a single parent and N >= 0 children.
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool