Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Node<D> *get_head() {
- return _head;
- }
- void TerTree<T>::map_element(TerTree<T> *tree, const Node<T> *node, T(*func)(const T &)) const;
- void TerTree<T>::map(TerTree<T> *tree, T(*func)(const T &)) const;
- ^^^^^^^^^^^ VSE ETO V class TerTree
- template <class T>
- void TerTree<T>::map_element(TerTree<T> *tree, const Node<T> *node, T(*func)(const T &)) const {
- if (node) {
- tree->addNode(func(node->getData()));
- if (node->getLeft())
- map_element(tree, node->getLeft(), func);
- if (node->getCenter())
- map_element(tree, node->getCenter(), func);
- if (node->getRight())
- map_element(tree, node->getRight(), func);
- }
- }
- template <class T>
- void TerTree<T>::map(TerTree<T> *tree, T(*func)(const T &)) const {
- if (!tree) {
- cout << "Nullptr passed as destination tree." << endl;
- return;
- }
- if (!func) {
- cout << "Nullptr passed as function." << endl;
- return;
- }
- map_element(tree, this->get_head(), func);
- }
- ^^^^^^^^^^^^^^^^^^^^^^^^^ VSE ETO VNE KLASSA TerTree
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement