<commit_before>var simpleCoverageAlgorithm = {

  execute: function(nodes, view) {

    var radius = nodes[0].radius;
    var diameter = radius * 2;
    // sort nodes
    nodes.sort(function(a,b){
      return a.x - b.x;
    });

    // adjust the nodes left
    // ajust the first node
    if (nodes[0].x - radius > 0) {
      var movement = (nodes[0].x - radius);
      nodes[0].x = nodes[0].x - movement; // allign it with 0
      update(view, movement, nodes);
      // update the view
    }

    for (i = 1, i < nodes.length; i++) {
      if (nodes[i].x - nodes[i-1].x > diameter) {
        // shift it to optimally cover the gap the distance between the 2 nodes is = to the diameter
        var movement = ((nodes[i].x - nodes[i-1].x) - diameter);
        nodes[i].x = nodes[i].x - movement;
        update(view, movement, nodes);
      }  // else: we overlap or the radius or the gap is perfectly covered.

    }

    // check the right bound of the interval
    // if gap to the right bound, we need to shift everything right
    if (1 - nodes[nodes.length - 1].x > radius) {
      // shift the right most node
      var movement = ((1 - nodes[nodes.length - 1].x) - radius);
      nodes[nodes.length -1].x =  nodes[nodes.length -1].x + movement;
      update(view, movement, nodes);
      // check to make sure no other gaps formed
      for (j = nodes.length - 2; j >= 0; j--) {
        if (nodes[j+1].x - nodes[j].x > diameter) {
          // shift it to optimally cover the gap the distance between the 2 nodes is = to the diameter
          var movement = ((nodes[i].x - nodes[i-1].x) - diameter);
          nodes[j].x = nodes[i].x + movement;
          update(view, movement, nodes);
        } else {
          // as soon as there is no gap, we are good as the first pass covered everything
          break;
        }
      }
    } // else the area is covered.

  },<commit_msg>update functionality<commit_after>var simpleCoverageAlgorithm = {

  execute: function(nodes, view) {

    var radius = nodes[0].radius;
    var diameter = radius * 2;
    // sort nodes
    nodes.sort(function(a,b){
      return a.x - b.x;
    });
    // starts the process
    checkLeft(nodes, view);

  }, // else the area is covered.
  moveRight: function(nodes, p, view) {
    if (nodes[p].x - nodes[p-1].x > diameter) {
      // shift it to optimally cover the gap the distance between the 2 nodes is = to the diameter
      var movement = ((nodes[p].x - nodes[p-1].x) - diameter);
      nodes[p].x = nodes[p].x - movement;
      update(view, movement, nodes);
    }  // else: we overlap or the radius or the gap is perfectly covered.

    if (position < nodes.lenght) {
      setTimeout(function() {
        moveRight(nodes, p++, view);
      }, view.delay);
    } else {
      checkRight(nodes);
    }
  },
  moveLeft: function (nodes, p, view) {
    if (nodes[p+1].x - nodes[p].x > diameter) {
      // shift it to optimally cover the gap the distance between the 2 nodes is = to the diameter
      var movement = ((nodes[p].x - nodes[p-1].x) - diameter);
      nodes[p].x = nodes[p].x + movement;
      update(view, movement, nodes);

      if (p > 0) {
        setTimeout(function() {
          moveLeft(nodes, p--, view);
        }, view.delay);
      }
      // as soon as there is no gap, we are good as the first pass covered everything
  },
  checkRight: function(nodes, view){
    if (1 - nodes[nodes.length - 1].x > radius) {
      // shift the right most node
      var movement = ((1 - nodes[nodes.length - 1].x) - radius);
      nodes[nodes.length -1].x =  nodes[nodes.length -1].x + movement;
      update(view, movement, nodes);

      setTimeout(function() {
        moveLeft(nodes, nodes.length - 2, view);
      }, view.delay);
    } // we only move left if the need to shift to cover the right bound
  },
  checkLeft: function(nodes, view){
    if (nodes[0].x - radius > 0) {
      var movement = (nodes[0].x - radius);
      nodes[0].x = nodes[0].x - movement; // allign it with 0
      update(view, movement, nodes);
      // update the view
    }
    setTimeout(function() {
      moveRight(nodes, 1, view);
    }, view.delay);

  },
{'fraction_non_alphanumeric': 0.13986519017814156, 'fraction_numerical': 0.011073663938372653, 'mean_word_length': 2.126410835214447, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '3840799', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1281, 'n_words': 434}