The aim of this project is to reproduce some of basic STL-containers:
All containers are located in the ft namespace
ft::map and ft::set implementations are using red-black tree under the hood.
ft::rbt implemented as a independent container and could be used separately from set or map.
#include "rbt.hpp"
int main() {
ft::rbt<int> tree;
for (int i = 1; i < 10; i++) {
tree.insert(i);
}
tree.erase(6);
return 0;
}The visualizer implemented as a separated template class, with the same value type as the tree.
These lines
#include "rbt.hpp"
#include "rbt_visualizer.hpp"
int main() {
ft::rbt<int> tree;
for (int i = 1; i < 20; i++) {
tree.insert(rand() % 100);
}
tree.erase(65);
ft::rbt_visualizer rbv(tree);
// or
// ft::rbt_visualizer rbv;
// rbv.visualize(tree);
return 0;
}will produce this output to stdout:
Large trees may not fit on the screen. In that case, zoom out to see the correct tree picture
To compile properly you need to explicitly specify the path to the main folder of this repo.
For example:
clang++ test.cpp -I ~/Desktop/STL-containersUse Makefile to change following vars:
INCLUDE_DIRto specify root folder of your containersCONT_SRCSto specify list of all not .hpp files of your container (if there are)DEBUGto compile tests with debug flagCYCLESto change amount of the test's runsOUTPUT_FTandOUTPUT_STDto set custom output filenameTESTER_FTandTESTER_STDto set custom tester executable name
Run make and tester will compare the output from the stl containers to ft automatically.
If no differences found, output files and tester executables will be removed.
Otherwise, you can compare output files manually and find mismatches. Tester executables won't be deleted as well, so you could run them and debug by yourself.

