<commit_before>#include "ranking.h"

using namespace std;

void Ranking::load(){
  try {
    Player player;
    ifstream file("ranking.dat", ios::binary);

    while (file.read((char*) &player, sizeof(Player)))
      this->players.append(player);

    file.close();
  } catch (exception &e) {
    cout << "\n" << "ranking.dat not found" << "\n";
  }
}

void Ranking::show(){
  Node<Player>* walker = this->players.getHead();
  Player player;

  cout << "\n-------------------------------";
  cout << "\n          HALL OF FAME         ";
  cout << "\n-------------------------------";

  while (walker != NULL){
    player = walker->data;

    cout << "\n";
    cout << setw(30) << player.getLogin();
    cout << setw(20) << player.getScore().get();

    walker = walker->next;
  }
}

bool Ranking::newRecord(Player& player){
  if (this->players.isEmpty())
    return true;

  Node<Player>* walker = this->players.getHead();

  while (walker != NULL && walker->data.getScore() > player.getScore())
    walker = walker->next;

  return walker == NULL || walker->data.getScore() <= player.getScore();
}

void Ranking::update(Player &player){
  this->insert(player);

  this->save();
}

void Ranking::insert(Player &player){
  Node<Player>* walker = this->players.getHead();

  while (walker != NULL && walker->data.getScore() > player.getScore())
    walker = walker->next;

  this->players.insert(walker, player);
}

void Ranking::save(){
  try {
    Node<Player>* walker = this->players.getHead();
    ofstream file("ranking.dat", ios::binary);
<commit_msg>Updated Ranking to insert before in the hall of fame list.<commit_after>#include "ranking.h"

using namespace std;

void Ranking::load(){
  try {
    Player player;
    ifstream file("ranking.dat", ios::binary);

    while (file.read((char*) &player, sizeof(Player)))
      this->players.append(player);

    file.close();
  } catch (exception &e) {
    cout << "\n" << "ranking.dat not found" << "\n";
  }
}

void Ranking::show(){
  Node<Player>* walker = this->players.getHead();
  Player player;

  cout << "\n-------------------------------";
  cout << "\n          HALL OF FAME         ";
  cout << "\n-------------------------------";

  while (walker != NULL){
    player = walker->data;

    cout << "\n";
    cout << setw(30) << player.getLogin();
    cout << setw(20) << player.getScore().get();

    walker = walker->next;
  }
}

bool Ranking::newRecord(Player& player){
  if (this->players.isEmpty())
    return true;

  Node<Player>* walker = this->players.getHead();

  while (walker != NULL && walker->data.getScore() > player.getScore())
    walker = walker->next;

  return walker == NULL || walker->data.getScore() <= player.getScore();
}

void Ranking::update(Player &player){
  this->insert(player);

  this->save();
}

void Ranking::insert(Player &player){
  Node<Player>* walker = this->players.getHead();

  while (walker != NULL && walker->data.getScore() > player.getScore())
    walker = walker->next;

  this->players.insertBefore(walker, player);
}

void Ranking::save(){
  try {
    Node<Player>* walker = this->players.getHead();
    ofstream file("ranking.dat", ios::binary);

{'fraction_non_alphanumeric': 0.22352197281062283, 'fraction_numerical': 0.002529244388239014, 'mean_word_length': 2.906172839506173, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 47, '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': '5582856', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1020, 'n_words': 230}