<commit_before>#include "freeway.h"
#include <cstdio>

#ifdef _LP64
#define __PRIS_PREFIX "z"
#else
#define __PRIS_PREFIX
#endif

#define PRIuS __PRIS_PREFIX "u"

namespace oop_project {

Freeway::Freeway(size_t num_segments,  size_t segment_ready_percent,
                 const size_t* segment_capacities, size_t toll_pass_limit) {
  num_cars_ = 0;
  size_t current_id = Junction::current_id();
  segments_.resize(num_segments);
  for (size_t i = 0; i < segments_.size(); ++i) {
    Segment* prev = NULL;
    if (i >= 1) {
      prev = segments_[i - 1];
    }

    segments_[i] = new Segment(segment_capacities[i], prev,
                               segment_ready_percent,
                               current_id + num_segments + 1,
                               toll_pass_limit);
    num_cars_ += segments_[i]->num_cars();
  }
  printf("The freeway is in operation.\n");
}

Freeway::~Freeway() {
  for (size_t i = 0; i < segments_.size(); ++i) {
    delete segments_[i];
  }
}

void Freeway::Operate() {
  num_cars_ = 0;
  for (int i = segments_.size() - 1; i >= 0; --i) {
    segments_[i]->Operate();
    num_cars_ += segments_[i]->num_cars();
  }
  printf("Cars: %" PRIuS "\n", num_cars_);
}

size_t Freeway::num_cars() const {
  return num_cars_;
}
<commit_msg>Freeway: Setting the next segment<commit_after>#include "freeway.h"
#include <cstdio>

#ifdef _LP64
#define __PRIS_PREFIX "z"
#else
#define __PRIS_PREFIX
#endif

#define PRIuS __PRIS_PREFIX "u"

namespace oop_project {

Freeway::Freeway(size_t num_segments,  size_t segment_ready_percent,
                 const size_t* segment_capacities, size_t toll_pass_limit) {
  num_cars_ = 0;
  size_t current_id = Junction::current_id();
  segments_.resize(num_segments);
  for (size_t i = 0; i < segments_.size(); ++i) {
    Segment* prev = NULL;
    if (i >= 1) {
      prev = segments_[i - 1];
    }

    segments_[i] = new Segment(segment_capacities[i], prev,
                               segment_ready_percent,
                               current_id + num_segments + 1,
                               toll_pass_limit);
    if (i >= 1) {
      prev->set_next(segments_[i]);
    }
    num_cars_ += segments_[i]->num_cars();
  }
  printf("The freeway is in operation.\n");
}

Freeway::~Freeway() {
  for (size_t i = 0; i < segments_.size(); ++i) {
    delete segments_[i];
  }
}

void Freeway::Operate() {
  num_cars_ = 0;
  for (int i = segments_.size() - 1; i >= 0; --i) {
    segments_[i]->Operate();
    num_cars_ += segments_[i]->num_cars();
  }
  printf("Cars: %" PRIuS "\n", num_cars_);
}

size_t Freeway::num_cars() const {
  return num_cars_;
}

{'fraction_non_alphanumeric': 0.14253048780487804, 'fraction_numerical': 0.008765243902439025, 'mean_word_length': 2.7661406025824964, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '7507330', 'n_tokens_mistral': 991, 'n_tokens_neox': 955, 'n_words': 208}