<commit_before>#include <new>

#include "utils.h"

using namespace std;

Container::Container()
{
  head_ = NULL;
  tail_ = NULL;
  current_ = NULL;
}

bool Container::add(ITEM* newItem)
{
  // Instead of throwing bad_alloc return a NULL pointer
  C_ELEMENT* newElement = new (nothrow) C_ELEMENT;
  if (newElement == NULL) {
    return false;
  }

  if (tail_ != NULL) {
    tail_->next = newElement;
  } else {
    head_ = newElement;
  }
  newElement->item = newItem;
  newElement->previous = tail_;
  newElement->next = NULL;
  tail_ = newElement;
  return true;
}

bool Container::remove()
{
  if (current_ == NULL) return false;
  
  C_ELEMENT* oldElement = current_;
  current_ = oldElement->next;
  if (current_ != NULL) {
    current_->previous = oldElement->previous;
  } else {
    tail_ = oldElement->previous;
  }
  current_ = oldElement->previous;
  if (current_ != NULL) {
    current_->next = oldElement->next;
  } else {
    head_ = oldElement->next;
  }
  delete oldElement->item;
  delete oldElement;

  return true;
}

void Container::begin()
{
  current_ = head_;
}

void Container::next()
{
  if (current_ != NULL) current_ = current_->next;
}

ITEM* Container::getItem()
{
  if (current_ != NULL) {
    return current_->item;
  } else {
    return NULL;
  }
}
<commit_msg>Adds mostly cleanup<commit_after>#include <new>

#include "utils.h"

using namespace std;

Container::Container()
{
  head_ = NULL;
  tail_ = NULL;
  current_ = NULL;
}

bool Container::add(ITEM* newItem)
{
  // Instead of throwing bad_alloc return a NULL pointer
  C_ELEMENT* newElement = new (nothrow) C_ELEMENT;
  if (newElement == NULL) {
    return false;
  }

  if (tail_ != NULL) {
    tail_->next = newElement;
  } else {
    head_ = newElement;
  }
  newElement->item = newItem;
  newElement->previous = tail_;
  newElement->next = NULL;
  tail_ = newElement;
  return true;
}

bool Container::remove()
{
  C_ELEMENT* oldElement = current_;
  if (current_ == NULL) return false;
   
  current_ = oldElement->next;
  // Check if old element was tail
  if (current_ != NULL) {
    current_->previous = oldElement->previous;
  } else {
    tail_ = oldElement->previous;
  }

  current_ = oldElement->previous;
  // Check if old element was head
  if (current_ != NULL) {
    current_->next = oldElement->next;
  } else {
    head_ = oldElement->next;
    begin();
  }
  delete oldElement->item;
  delete oldElement;

  return true;
}

void Container::begin()
{
  current_ = head_;
}

void Container::next()
{
  if (current_ != NULL) current_ = current_->next;
}

ITEM* Container::getItem()
{
  if (current_ != NULL) {
    return current_->item;
  } else {
    return NULL;
  }
}

{'fraction_non_alphanumeric': 0.1347517730496454, 'fraction_numerical': 0.0, 'mean_word_length': 3.240506329113924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '4695851', 'n_tokens_mistral': 921, 'n_tokens_neox': 917, 'n_words': 235}