aboutsummaryrefslogtreecommitdiff
path: root/btree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'btree.cpp')
-rw-r--r--btree.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/btree.cpp b/btree.cpp
index 0ac794f..8c32b1f 100644
--- a/btree.cpp
+++ b/btree.cpp
@@ -3,6 +3,7 @@
* Author: Aryadev Chavali
*/
+#include <iostream>
enum Order
{
@@ -50,3 +51,27 @@ BinaryTree<T> *insert(BinaryTree<T> *tree, T value)
return tree;
}
+int main(void)
+{
+ auto tree = new BinaryTree<int>;
+ tree->value = 5;
+ tree->compare = [](int x, int y) {
+ if (x < y)
+ return LT;
+ else if (x > y)
+ return GT;
+ else
+ return EQ;
+ };
+
+ for (int i = 0; i <= 5; ++i)
+ {
+ tree = insert(tree, i * 2);
+ }
+
+ std::cout << tree->left->value << ", "
+ << tree->value << ", "
+ << tree->right->value << std::endl;
+ delete tree;
+ return 0;
+}