In a few words:
A no-frills template-driven binary tree using C++ 11 / 14 / 17 features. No balancing, no fancy stuff really, apart from some template syntax that might be a bit on the wtf side (but not too much). Went a bit overkill with both templates and smart pointers, but the reason behind writing this small tree was precisely to fiddle with those things.
Note: Needs C++ 17 compiler to build... obviously.
- Only two main classes at work: BinaryTree<T> and Node<T>.
- The tree is doubly-linked, meaning each Node holds two shared_ptr's to its children and a weak_ptr to its parent (to avoid circular dependency issues).
- The usual insert(), remove(), findMin(), findMax() etc. methods are implemented, as well as a (deep) copy constructor and copy assignment operator, among other things.
- The tree supports both depth-first (4 modes) and breadth-first (2 modes) traversal. Because of a multitude of methods needing to traverse the tree, a design decision was made to have a single traverse() method that accepts a function pointer to the function performing the actual action on the nodes (e.g. print, remove, copy).
Can't think of anything else interesting to mention, like I said, this was just an exercise with a bit of beyond-the-basics templates and modern C++ features. If anything, it can serve as demonstration of some template syntax for later reference.
Check out Bitbucket repo.