summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas <Jonas@Jonas-PC> 2017-02-10 19:33:19 +0100
committerGravatar Jonas <Jonas@Jonas-PC> 2017-02-10 19:33:19 +0100
commitc7e1a088c886a36f4164d0bbd968bb1338963c9e (patch)
tree77fbf3b2c9bed8df39ebd4f348afb8f59f39293d
parentd0d4d1682a2d6b641efe2c8e7e40cdae30b0d8eb (diff)
downloadtree-c7e1a088c886a36f4164d0bbd968bb1338963c9e.tar.gz
mis fixes, tweaks
-rw-r--r--tree/src/cNode.cpp3
-rw-r--r--tree/src/cNode.h7
2 files changed, 7 insertions, 3 deletions
diff --git a/tree/src/cNode.cpp b/tree/src/cNode.cpp
index 4597e7c..95b6c45 100644
--- a/tree/src/cNode.cpp
+++ b/tree/src/cNode.cpp
@@ -36,7 +36,8 @@ void cDatanode::insert(cData* _data, cNode** _me)
{
if (*_data > *data)
nextBigger->insert(_data, &nextBigger);
- //TODO Add equals check to prevent double insertion!
+ else if (*_data == *data)
+ return; //data already exists, abort
else
nextSmaller->insert(_data, &nextSmaller);
}//insert
diff --git a/tree/src/cNode.h b/tree/src/cNode.h
index c8ffe50..8bbc915 100644
--- a/tree/src/cNode.h
+++ b/tree/src/cNode.h
@@ -39,10 +39,12 @@ public:
virtual cData* getById(unsigned int, unsigned int&) = 0;
/*
* searches for obejct ID (-> inorder)
+ * int: wanted if
+ * int&: id counter
*/
virtual void getSortet(list<cData>* _list) = 0;
/*
- * gets sortet list
+ * saves inorder list to *_list
*/
virtual unsigned int getSubtreeSize() = 0;
/*
@@ -51,10 +53,11 @@ public:
virtual unsigned int getDepth(unsigned int) = 0;
/*
* returns maximum depth under node
+ * unsigned int: depth of parent
*/
virtual void draw(int _depth) = 0;
/*
- *
+ *draws tree in Ascii
*/
};