#ifndef NODE_H #define NODE_H #include #include #include #include #include #include class Node { public: Node(const std::string &name = ""); virtual ~Node(); std::string get_name() const; void set_name(const std::string &new_name); int get_nr_children() const; Node *get_child(int i) const; void add_child(Node *child); void print(std::ostream &str = std::cout, uint32_t depth = 0) const; static Node *create_complete_tree(uint32_t nr_child_nodes, uint32_t tree_depth); static void traverse_tree(const Node *node, std::function predicate, bool recursive, uint32_t depth = 0); private: std::string name; std::vector children; static uint32_t node_id; static void traverse_tree_recursive(const Node *node, std::function predicate, std::set &visited, uint32_t depth = 0); static void traverse_tree_iterative(const Node *node, std::function predicate, uint32_t depth = 0); }; extern std::ostream &operator<<(std::ostream &os, const Node *node); #endif // NODE_H