<commit_before>#include <iostream>
#include "splay_tree.hpp"
#include <string>

struct Node {
  Node* parent;
  Node* left;
  Node* right;
  int key;
  
  Node(int k): key(k){
    left = right = nullptr;
    parent = nullptr;
  }
};

void rightRotate(Node* n) {
  Node* new_root = n->left;
  
  n->left = new_root->right;
  
  new_root->right = n;
  
  new_root->parent = n->parent;
  
  n->parent = new_root;
  
  if (n->left != nullptr){
    n->left->parent = n;
  }
  
  if (new_root->parent != nullptr and new_root->parent->left == n){
    new_root->parent->left = new_root;
  }
  else if (new_root->parent != nullptr) {
    new_root->parent->right = new_root;
  }
}

void leftRotate(Node* n) {
  Node* new_root = n->right;
  
  n->right = new_root->left;
  
  new_root->left = n;
  
  new_root->parent = n->parent;
  
  n->parent = new_root;
  
  if (n->right != nullptr) {
    n->right->parent = n;
  }
  
  if (new_root->parent != nullptr and new_root->parent->left == n) {
    new_root->parent->left = new_root;
  }
  else if (new_root->parent != nullptr) {
    new_root->parent->right = new_root;
  }
}
void printNode(Node* node, std::string prefix, bool isTail){
    if (node == nullptr){
      return;
    }
    std::cout << (prefix + (isTail ? "└── " : "├── ")) << node->key << std::endl;
    if (node->left != nullptr){
      printNode(node->right, (prefix + (isTail ? "    " : "│   ")), false);
      printNode(node->left, (prefix + (isTail ? "    " : "│   ")), true);
    }
    else {
      printNode(node->right, (prefix + (isTail ? "    " : "│   ")), true);
    }
}

int main(){
  dicts::SplayDict<int, std::string > spDict;
  spDict.set(1,"aaa");
  //std::cout << spDict << std::endl;
  spDict.set(2,"baa");
  //std::cout << spDict << std::endl;
  spDict.set(-1,"baa");
  //std::cout << spDict << std::endl;
  spDict.set(0,"baa");
  //std::cout << spDict << std::endl;
  spDict.set(-2,"baa");
  //std::cout << spDict << std::endl;
  spDict.set(-3,"baa");
  //std::cout << spDict << std::endl;
  spDict.set(5,"baa");
  //std::cout << spDict << std::endl;

  spDict.erase(2);
  std::cout << spDict << std::endl;

  
  dicts::SplayDict<int, std::string>::ConstIterator it = spDict.begin();
  
  std::cout << spDict << std::endl;
  for(it = spDict.begin(); it != spDict.end(); it++){
    std::cout<< (*it).first <<" "<<(*it).second<<std::endl;
      
  }
  
  std::cout<<spDict.get(1)<<std::endl;
  
  std::cout << spDict << std::endl;
  
  
}
<commit_msg>Splay Tree: cleaning up the example<commit_after>#include <iostream>
#include "splay_tree.hpp"
#include <string>

int main(){
  dicts::SplayDict<int, std::string > spDict;
  spDict.set(1,"aaa");
  //std::cout << spDict << std::endl;
  spDict.set(2,"baa");
  //std::cout << spDict << std::endl;
  spDict.set(-1,"baa");
  //std::cout << spDict << std::endl;
  spDict.set(0,"baa");
  //std::cout << spDict << std::endl;
  spDict.set(-2,"baa");
  //std::cout << spDict << std::endl;
  spDict.set(-3,"baa");
  //std::cout << spDict << std::endl;
  spDict.set(5,"baa");
  //std::cout << spDict << std::endl;

  spDict.erase(2);
  std::cout << spDict << std::endl;

  
  dicts::SplayDict<int, std::string>::ConstIterator it = spDict.begin();
  
  std::cout << spDict << std::endl;
  for(it = spDict.begin(); it != spDict.end(); it++){
    std::cout<< (*it).first <<" "<<(*it).second<<std::endl;
      
  }
  
  std::cout<<spDict.get(1)<<std::endl;
  
  std::cout << spDict << std::endl;
  
  
}

{'fraction_non_alphanumeric': 0.2296124927703875, 'fraction_numerical': 0.005205320994794679, 'mean_word_length': 3.117857142857143, 'pattern_counts': {'":': 0, '<': 121, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5487615', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1375, 'n_words': 250}