Getting Started
Add the library and run your first tree
This page covers installation, the public include path, a first working example, direct compiler usage, and the CMake-based build flow used by the repository itself.
Requirements
- A compiler with C++17 support
- No external dependencies
- Access to the repository's
include/directory
Installation
Copy the repository's include/ directory into your project and point the compiler include path at it.
Include
#include <bst/bst.h>
You can also keep the repository as a submodule if you want to track updates directly.
Bash
git submodule add https://github.com/Brxj19/Binary-Search-Tree.git external/Binary-Search-Tree
Quick example
This example inserts values, erases one value, and iterates in sorted order.
C++
#include <iostream>
#include <bst/bst.h>
int main() {
BinarySearchTree<int> tree = {8, 3, 10, 1, 6};
tree.insert(14);
tree.erase(3);
for (int value : tree) {
std::cout << value << ' ';
}
std::cout << '\n';
}
Direct compiler build
Use this when you want the quickest possible test outside CMake.
Bash
g++ -std=c++17 -Wall -Wextra -Wpedantic your_program.cpp -I/path/to/include -o your_program
CMake build
The repository includes an interface library target, test executable, and example executables.
Bash
mkdir build
cd build
cmake ..
cmake --build .
ctest --output-on-failure
Next steps
- Browse the API Reference to understand insertion, iterators, and utility methods.
- Check the Examples page for custom comparators and traversal helpers.
- Read the Performance page before using the container with sorted input patterns.