<commit_before>export { DEvolution_VersusId as VersusId };

import * as Pool from "../../util/Pool.js";
import * as Recyclable from "../../util/Recyclable.js";
import * as NumberTools from "../../util/NumberTools.js";

/**
 * @member {string} versusIdString
 *   The versus id string (e.g. EntityNo_ParentGenerationNo_OffspringGenerationNo).
 *
 * @member {string} entityNoString
 *   The entity id string of the versus.
 *
 * @member {number} entityNo
 *   The entity id number of the versus. It is a 1-base integer.
 *
 * @member {string} parentGenerationNoString
 *   The parent generation id string of the entity of the versus.
 *
 * @member {number} parentGenerationNo
 *   The parent generation id number of the entity of the versus. It is a 0-base integer.
 *
 * @member {string} offspringGenerationNoString
 *   The offspring generation id string of the entity of the versus.
 *
 * @member {number} offspringGenerationNo
 *   The offspring generation id number of the entity of the versus. It is a 0-base
 * integer.
 */
class DEvolution_VersusId extends Recyclable.Root {

  /**
   * Used as default DEvolution.VersusId provider for conforming to Recyclable interface.
   */
  static Pool = new Pool.Root( "DEvolution.VersusId.Pool",
    DEvolution_VersusId, DEvolution_VersusId.setAsConstructor );

  /** */
  constructor( versusIdString ) {
    super();
    DEvolution_VersusId.setAsConstructor_self.call( this, versusIdString );
  }

  /** @override */
  static setAsConstructor( versusIdString ) {
    super.setAsConstructor();
    DEvolution_VersusId.setAsConstructor_self.call( this, versusIdString );
    return this;
  }

  /** @override */
  static setAsConstructor_self( versusIdString ) {
    this.set_byVersusIdString( versusIdString );
  }

  /** @override */
  disposeResources() {
    this.offspringGenerationNo = undefined;
    this.offspringGenerationNoString = undefined;
    this.parentGenerationNo = undefined;
    this.parentGenerationNoString = undefined;
    this.entityNo = undefined;
    this.entityNoString = undefined;
    this.versusIdString = undefined;
    super.disposeResources();
  }

  /**
   *
   * @param {string} versusIdString
   *   The versus id string (e.g. EntityNo_ParentGenerationNo_OffspringGenerationNo).
   */
  set_byVersusIdString( versusIdString ) {

    // Split the versus id inside. Got id of entity, parentGeneration,
    // offspringGeneration.
    //
    //   EntityNo_ParentGenerationNo_OffspringGenerationNo
    //
    // They are separated by underline (_).
    let versusId_parts = versusIdString.split(
      DEvolution_VersusId
        .EntityNo_ParentGenerationNo_OffspringGenerationNo_SplittingRegExp,
      3 // Just parse three parts.
    );

    this.versusIdString = versusIdString;
    this.entityNoString = versusId_parts[ 0 ];
    this.entityNo = Number.parseInt( this.entityNoString, 10 );
    this.parentGenerationNoString = versusId_parts[ 1 ];
    this.parentGenerationNo = Number.parseInt( this.parentGenerationNoString, 10 );
    this.offspringGenerationNoString = versusId_parts[ 2 ];
    this.offspringGenerationNo = Number.parseInt( this.offspringGenerationNoString, 10 );
  }

  /**
   * @return {boolean} Reurn true, if these ids are legal.
   */
  isValid() {
    if ( !NumberTools.isInteger( this.entityNo ) )
      return false;
    if ( this.entityNo < ???1 ) // entity id is 1-base.
      return false;

    if ( !NumberTools.isInteger( this.parentGenerationNo ) )
      return false;
    if ( this.parentGenerationNo < 0 ) // generation id is 0-base.
      return false;

    if ( !NumberTools.isInteger( this.offspringGenerationNo ) )
      return false;
    if ( this.offspringGenerationNo < 0 ) // generation id is 0-base.
      return false;

    return true;
  }

}

/**
 * Regular expression for splitting ids of entity, parent generation,
 * offspring generation.
 */
DEvolution_VersusId.EntityNo_ParentGenerationNo_OffspringGenerationNo_SplittingRegExp
  = RegExp( "_", "g" );
<commit_msg>entity id is 0-base.<commit_after>export { DEvolution_VersusId as VersusId };

import * as Pool from "../../util/Pool.js";
import * as Recyclable from "../../util/Recyclable.js";
import * as NumberTools from "../../util/NumberTools.js";

/**
 * @member {string} versusIdString
 *   The versus id string (e.g. EntityNo_ParentGenerationNo_OffspringGenerationNo).
 *
 * @member {string} entityNoString
 *   The entity id string of the versus.
 *
 * @member {number} entityNo
 *   The entity id number of the versus. It is a 0-base integer.
 *
 * @member {string} parentGenerationNoString
 *   The parent generation id string of the entity of the versus.
 *
 * @member {number} parentGenerationNo
 *   The parent generation id number of the entity of the versus. It is a 0-base integer.
 *
 * @member {string} offspringGenerationNoString
 *   The offspring generation id string of the entity of the versus.
 *
 * @member {number} offspringGenerationNo
 *   The offspring generation id number of the entity of the versus. It is a 0-base
 * integer.
 */
class DEvolution_VersusId extends Recyclable.Root {

  /**
   * Used as default DEvolution.VersusId provider for conforming to Recyclable interface.
   */
  static Pool = new Pool.Root( "DEvolution.VersusId.Pool",
    DEvolution_VersusId, DEvolution_VersusId.setAsConstructor );

  /** */
  constructor( versusIdString ) {
    super();
    DEvolution_VersusId.setAsConstructor_self.call( this, versusIdString );
  }

  /** @override */
  static setAsConstructor( versusIdString ) {
    super.setAsConstructor();
    DEvolution_VersusId.setAsConstructor_self.call( this, versusIdString );
    return this;
  }

  /** @override */
  static setAsConstructor_self( versusIdString ) {
    this.set_byVersusIdString( versusIdString );
  }

  /** @override */
  disposeResources() {
    this.offspringGenerationNo = undefined;
    this.offspringGenerationNoString = undefined;
    this.parentGenerationNo = undefined;
    this.parentGenerationNoString = undefined;
    this.entityNo = undefined;
    this.entityNoString = undefined;
    this.versusIdString = undefined;
    super.disposeResources();
  }

  /**
   *
   * @param {string} versusIdString
   *   The versus id string (e.g. EntityNo_ParentGenerationNo_OffspringGenerationNo).
   */
  set_byVersusIdString( versusIdString ) {

    // Split the versus id inside. Got id of entity, parentGeneration,
    // offspringGeneration.
    //
    //   EntityNo_ParentGenerationNo_OffspringGenerationNo
    //
    // They are separated by underline (_).
    let versusId_parts = versusIdString.split(
      DEvolution_VersusId
        .EntityNo_ParentGenerationNo_OffspringGenerationNo_SplittingRegExp,
      3 // Just parse three parts.
    );

    this.versusIdString = versusIdString;
    this.entityNoString = versusId_parts[ 0 ];
    this.entityNo = Number.parseInt( this.entityNoString, 10 );
    this.parentGenerationNoString = versusId_parts[ 1 ];
    this.parentGenerationNo = Number.parseInt( this.parentGenerationNoString, 10 );
    this.offspringGenerationNoString = versusId_parts[ 2 ];
    this.offspringGenerationNo = Number.parseInt( this.offspringGenerationNoString, 10 );
  }

  /**
   * @return {boolean} Reurn true, if these ids are legal.
   */
  isValid() {
    if ( !NumberTools.isInteger( this.entityNo ) )
      return false;
    if ( this.entityNo < 0 ) // entity id is 0-base.
      return false;

    if ( !NumberTools.isInteger( this.parentGenerationNo ) )
      return false;
    if ( this.parentGenerationNo < 0 ) // generation id is 0-base.
      return false;

    if ( !NumberTools.isInteger( this.offspringGenerationNo ) )
      return false;
    if ( this.offspringGenerationNo < 0 ) // generation id is 0-base.
      return false;

    return true;
  }

}

/**
 * Regular expression for splitting ids of entity, parent generation,
 * offspring generation.
 */
DEvolution_VersusId.EntityNo_ParentGenerationNo_OffspringGenerationNo_SplittingRegExp
  = RegExp( "_", "g" );

{'fraction_non_alphanumeric': 0.09947447447447448, 'fraction_numerical': 0.00487987987987988, 'mean_word_length': 3.4111479028697573, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '5883731', 'n_tokens_mistral': 2382, 'n_tokens_neox': 2331, 'n_words': 619}