aboutsummaryrefslogtreecommitdiff
path: root/btree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'btree.cpp')
-rw-r--r--btree.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/btree.cpp b/btree.cpp
index 8c32b1f..741c8f7 100644
--- a/btree.cpp
+++ b/btree.cpp
@@ -40,22 +40,24 @@ BinaryTree<T> *insert(BinaryTree<T> *tree, T value)
break;
}
- if (*node) {
+ if (*node)
+ {
*node = insert(*node, value);
return tree;
}
- *node = new BinaryTree<T>;
+ *node = new BinaryTree<T>;
(*node)->value = value;
(*node)->left = (*node)->right = nullptr;
- (*node)->compare = tree->compare;
+ (*node)->compare = tree->compare;
return tree;
}
int main(void)
{
- auto tree = new BinaryTree<int>;
- tree->value = 5;
- tree->compare = [](int x, int y) {
+ auto tree = new BinaryTree<int>;
+ tree->value = 5;
+ tree->compare = [](int x, int y)
+ {
if (x < y)
return LT;
else if (x > y)
@@ -65,9 +67,7 @@ int main(void)
};
for (int i = 0; i <= 5; ++i)
- {
tree = insert(tree, i * 2);
- }
std::cout << tree->left->value << ", "
<< tree->value << ", "