// Una rotación cambia la forma y conserva el recorrido en orden.
#include <iostream>
#include <vector>

#include "avl_set.h"

// Deja a este programa rotar a mano, sin el resto de la reparación.
struct AvlSetAccess {
    static void rotate_root_right(AvlSet<int>& tree) { tree.root_ = tree.rotate_right(tree.root_); }
    static void rotate_root_left(AvlSet<int>& tree) { tree.root_ = tree.rotate_left(tree.root_); }
};

void show(const char* title, const AvlSet<int>& tree) {
    std::cout << title << ": " << tree.shape() << "\n  en orden:";
    for (int key : tree.in_order()) {
        std::cout << " " << key;
    }
    std::cout << "\n";
}

int main() {
    AvlSet<int> tree;
    for (int key : {40, 20, 60, 10, 30}) {
        tree.insert(key);
    }
    show("inicio", tree);
    AvlSetAccess::rotate_root_right(tree);
    show("rotar a la derecha en 40", tree);
    AvlSetAccess::rotate_root_left(tree);
    show("rotar a la izquierda en 20", tree);
    return 0;
}
