public class TestRBTree {
  public static void main(String[] args) {
    // Tworzenie drzewa czerwono-czarnego
    RBTree<Integer> tree = new RBTree<>(new Integer[]{34, 3, 50});
    printTree(tree);
    
    tree.insert(20);
    printTree(tree);

    tree.insert(15);
    printTree(tree);

    tree.insert(16);
    printTree(tree);

    tree.insert(25);
    printTree(tree);

    tree.insert(27);
    printTree(tree);

    tree.delete(50);
    printTree(tree);

    tree.delete(20);
    printTree(tree);

    tree.delete(15);
    printTree(tree);

    tree.delete(3);
    printTree(tree);

    tree.delete(25);
    printTree(tree);

    tree.delete(16);
    printTree(tree);

    tree.delete(34);
    printTree(tree);

    tree.delete(27);
    printTree(tree);
  }

  public static <E extends Comparable<E>> 
      void printTree(BST<E> tree) {
    // Przechodzenie drzewa
    System.out.print("\nInorder (posortowane): ");
    tree.inorder();
    System.out.print("\nPostorder: ");
    tree.postorder();
    System.out.print("\nPreorder: ");
    tree.preorder();
    System.out.print("\nLiczba węzłów: " + tree.getSize());
    System.out.println();
  }
}
