00001 #include "PartitionTreeNode.hpp"
00002
00003 using namespace indii::ml::aux;
00004
00005 PartitionTreeNode::PartitionTreeNode() : size(0), left(NULL), right(NULL) {
00006
00007 }
00008
00009 PartitionTreeNode::PartitionTreeNode(const unsigned int i,
00010 const unsigned int depth) : flagLeaf(true), flagPrune(false),
00011 flagInternal(false), depth(depth), size(1), i(i), is(0), left(NULL),
00012 right(NULL) {
00013
00014 }
00015
00016 PartitionTreeNode::PartitionTreeNode(const std::vector<unsigned int>& is,
00017 const unsigned int depth) : flagLeaf(false), flagPrune(true),
00018 flagInternal(false), depth(depth), size(is.size()), i(0), is(is),
00019 left(NULL), right(NULL) {
00020
00021
00022 }
00023
00024 PartitionTreeNode::PartitionTreeNode(PartitionTreeNode* left,
00025 PartitionTreeNode* right, const unsigned int depth) : flagLeaf(false),
00026 flagPrune(false), flagInternal(true), depth(depth),
00027 size(left->getSize() + right->getSize()), i(0), is(0), left(left),
00028 right(right) {
00029
00030 }
00031
00032 PartitionTreeNode::PartitionTreeNode(const PartitionTreeNode& o) {
00033 flagLeaf = o.flagLeaf;
00034 flagPrune = o.flagPrune;
00035 flagInternal = o.flagInternal;
00036 depth = o.depth;
00037 size = o.size;
00038 i = o.i;
00039 is = o.is;
00040
00041 if (o.left == NULL) {
00042 left = NULL;
00043 } else {
00044 left = o.left->clone();
00045 }
00046
00047 if (o.right == NULL) {
00048 right = NULL;
00049 } else {
00050 right = o.right->clone();
00051 }
00052 }
00053
00054 PartitionTreeNode::~PartitionTreeNode() {
00055 delete left;
00056 delete right;
00057 }
00058
00059 PartitionTreeNode& PartitionTreeNode::operator=(const PartitionTreeNode& o) {
00060 flagLeaf = o.flagLeaf;
00061 flagPrune = o.flagPrune;
00062 flagInternal = o.flagInternal;
00063 depth = o.depth;
00064 size = o.size;
00065 i = o.i;
00066 is = o.is;
00067
00068 delete left;
00069 delete right;
00070
00071 if (o.left == NULL) {
00072 left = NULL;
00073 } else {
00074 left = o.left->clone();
00075 }
00076
00077 if (o.right == NULL) {
00078 right = NULL;
00079 } else {
00080 right = o.right->clone();
00081 }
00082
00083 return *this;
00084 }
00085