diff options
author | Pixel <> | 2001-02-28 11:40:25 +0000 |
---|---|---|
committer | Pixel <> | 2001-02-28 11:40:25 +0000 |
commit | 833d20a69fe17ab846c153e35230c66a41d8fca9 (patch) | |
tree | 180ba073e59fee8df22cb733be2eec4c452e1b85 /lib/HTree.cc |
Premier jetstart
Diffstat (limited to 'lib/HTree.cc')
-rw-r--r-- | lib/HTree.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/HTree.cc b/lib/HTree.cc new file mode 100644 index 0000000..c651f48 --- /dev/null +++ b/lib/HTree.cc @@ -0,0 +1,40 @@ +#include <stdio.h> +#include <iostream.h> +#include "config.h" +#include "HTree.h" + +HTree::HTree(int n_freq, char * n_objet) { + freq = n_freq; + objet = n_objet; + left = right = NULL; +} + +HTree::HTree(HTree * n_left, HTree * n_right) { + left = n_left; + right = n_right; + freq = n_left->freq + n_right->freq; + objet = NULL; +} + +HTree::~HTree() { + if (left) delete left; + if (right) delete right; +} + +ostream & HTree::Trace(ostream & os, int d) { + static char cmpr[MAX_HDEPTH + 1]; + if (objet) { + cmpr[d] = '\0'; + os << objet << " = " << cmpr << endl; + } else { + if (left) { + cmpr[d] = '0'; + left->Trace(os, d + 1); + } + if (right) { + cmpr[d] = '1'; + right->Trace(os, d + 1); + } + } + return os; +} |