// Sigue un árbol rojinegro inserción por inserción, con el árbol 2-3-4 que representa.
// Cada argumento es una clave: rb_trace 10 20 30 15 25
#include <cstdlib>
#include <iostream>

#include "rb_set.h"

int main(int argc, char** argv) {
    RedBlackSet<int> tree;
    for (int i = 1; i < argc; i++) {
        int key = std::atoi(argv[i]);
        tree.insert(key);
        tree.check_invariants();
        std::cout << "insertar " << key << ": " << tree.shape() << "\n";
        for (const auto& step : tree.last_steps()) {
            std::cout << "    en " << step.key << ": " << step.kind << "\n";
        }
        std::cout << "    2-3-4: " << tree.collapsed() << "\n";
    }
    std::cout << "altura " << tree.height() << ", negros " << tree.black_height() << ", rotaciones "
              << tree.rotations() << ", recoloreos " << tree.recolors() << "\n";
    return 0;
}
