From 0c4b90c4c4cfe7b65b0d2e66c3b34325e687fafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Tue, 24 Sep 2019 10:13:35 +0200 Subject: [PATCH] template functions to header --- libsrc/gprim/adtree.cpp | 6 +++--- libsrc/gprim/adtree.hpp | 42 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/libsrc/gprim/adtree.cpp b/libsrc/gprim/adtree.cpp index 0e4e7f6e..2f5ac117 100644 --- a/libsrc/gprim/adtree.cpp +++ b/libsrc/gprim/adtree.cpp @@ -1988,7 +1988,8 @@ namespace netgen } } */ - + + /* template void T_ADTree :: PrintRec (ostream & ost, const T_ADTreeNode * node) const { @@ -2030,8 +2031,7 @@ namespace netgen els += ElementsRec(node->right); return els; } - - +*/ diff --git a/libsrc/gprim/adtree.hpp b/libsrc/gprim/adtree.hpp index aa17c474..6ab7669e 100644 --- a/libsrc/gprim/adtree.hpp +++ b/libsrc/gprim/adtree.hpp @@ -609,9 +609,45 @@ public: int Elements () const { return ElementsRec (root); } - void PrintRec (ostream & ost, const T_ADTreeNode * node) const; - int DepthRec (const T_ADTreeNode * node) const; - int ElementsRec (const T_ADTreeNode * node) const; + void PrintRec (ostream & ost, const T_ADTreeNode * node) const + { + + // if (node->data) // true anyway + { + ost << node->pi << ": "; + ost << node->nchilds << " childs, "; + for (int i = 0; i < dim; i++) + ost << node->data[i] << " "; + ost << endl; + } + if (node->left) + PrintRec (ost, node->left); + if (node->right) + PrintRec (ost, node->right); + } + + int DepthRec (const T_ADTreeNode * node) const + { + int ldepth = 0; + int rdepth = 0; + + if (node->left) + ldepth = DepthRec(node->left); + if (node->right) + rdepth = DepthRec(node->right); + return 1 + max2 (ldepth, rdepth); + } + + int ElementsRec (const T_ADTreeNode * node) const + { + int els = 1; + if (node->left) + els += ElementsRec(node->left); + if (node->right) + els += ElementsRec(node->right); + return els; + } + void PrintMemInfo (ostream & ost) const {