<commit_before>( function _gLong_s_() {

'use strict';

let _global = _global_;
let _ = _global_.wTools;
let Self = _global_.wTools;

//

let _ArrayIndexOf = Array.prototype.indexOf;
let _ArrayLastIndexOf = Array.prototype.lastIndexOf;
let _ArraySlice = Array.prototype.slice;
let _ArraySplice = Array.prototype.splice;
let _FunctionBind = Function.prototype.bind;
let _ObjectToString = Object.prototype.toString;
// let Object.hasOwnProperty = Object.hasOwnProperty;
let _ObjectPropertyIsEumerable = Object.propertyIsEnumerable;

// --
// long transformer
// --

/**
 * The routine longOnce() returns the {-dstLong-} with the duplicated elements removed.
 * The {-dstLong-} instance will be returned when possible, if not a new instance of the same type is created.
 *
 * @param { Long } dstLong - The source and destination Long.
 * @param { Function } onEvaluate - A callback function.
 *
 * @example
 * _.longOnce( [ 1, 1, 2, 'abc', 'abc', 4, true, true ] );
 * // returns [ 1, 2, 'abc', 4, true ]
 *
 * @example
 * _.longOnce( [ 1, 2, 3, 4, 5 ] );
 * // returns [ 1, 2, 3, 4, 5 ]
 *
 * @example
 * _.longOnce( [ { v : 1 },{ v : 1 }, { v : 1 } ], ( e ) => e.v );
 * // returns [ { v : 1 } ]
 *
 * @example
 * _.longOnce( [ { v : 1 },{ v : 1 }, { v : 1 } ], ( e ) => e.k );
 * // returns [ { v : 1 },{ v : 1 }, { v : 1 } ]
 *
 * @returns { Long } - If it is possible, returns the source Long without the duplicated elements.
 * Otherwise, returns copy of the source Long without the duplicated elements.
 * @function longOnce
 * @throws { Error } If passed arguments is less than one or more than two.
 * @throws { Error } If the first argument is not an long.
 * @throws { Error } If the second argument is not a Routine.
 * @namespace Tools
 */

function longOnce( dstLong, onEvaluate )
{
  _.assert( 1 <= arguments.length || arguments.length <= 2 );
  _.assert( _.longIs( dstLong ), 'Expects Long' );

  if( _.arrayIs( dstLong ) )
  return _.arrayRemoveDuplicates( dstLong, onEvaluate );

  if( !dstLong.length )
  return dstLong;

  let length = dstLong.length;

  for( let i = 0; i < dstLong.length; i++ )
  if( _.longLeftIndex( dstLong, dstLong[ i ], i+1, onEvaluate ) !== -1 )
  length--;

  if( length === dstLong.length )
  return dstLong;

  let result = _.longMakeUndefined( dstLong, length );
  result[ 0 ] = dstLong[ 0 ];

  let j = 1;
  for( let i = 1; i < dstLong.length && j < length; i++ )
  if( _.longRightIndex( result, dstLong[ i ], j-1, onEvaluate ) === -1 )
  result[ j++ ] = dstLong[ i ];

  _.assert( j === length );

  return result;
}

//

function longOnce_( dstLong, srcLong, onEvaluate )
{
  _.assert( dstLong === null || _.longIs( dstLong ), 'Expects Long' );

  if( dstLong === null )
  {
    if( _.longIs( srcLong ) )
    dstLong = _.longMakeUndefined( srcLong, 0 );
    else
    return [];
  }
  if( arguments.length === 1 )
  {
    srcLong = dstLong;
  }
  else if( arguments.length === 2 )
  {
    if( _.routineIs( srcLong ) )
    {
      onEvaluate = arguments[ 1 ];
      srcLong = arguments[ 0 ];
    }
  }
  else if( arguments.length !== 3 )
  _.assert( 0 );

  _.assert( _.longIs( srcLong ) );

  let result;

  if( dstLong === srcLong )
  {
    if( !dstLong.length )
    return dstLong;

    if( _.arrayIs( dstLong ) )
    return _.arrayRemoveDuplicates( dstLong, onEvaluate );

    let length = dstLong.length;

    for( let i = 0; i < dstLong.length; i++ )
    if( _.longLeftIndex( dstLong, dstLong[ i ], i + 1, onEvaluate ) !== -1 )
    length--;

    if( length === dstLong.length )
    return dstLong;

    result = _.longMakeUndefined( dstLong, length );
    result[ 0 ] = dstLong[ 0 ];

    let j = 1;
    for( let i = 1; i < dstLong.length && j < length; i++ )
    if( _.longRightIndex( result, dstLong[ i ], j - 1, onEvaluate ) === -1 )
    result[ j++ ] = dstLong[ i ];

    _.assert( j === length );
  }
  else
  {
    if( _.arrayIs( dstLong ) )
    {
      result = _.arrayAppendArrayOnce( dstLong, srcLong, onEvaluate );
    }
    else
    {
      let length = srcLong.length + dstLong.length;

      for( let i = 0; i < srcLong.length; i++ )
      if( _.longLeftIndex( dstLong, srcLong[ i ], onEvaluate ) !== -1 || _.longLeftIndex( srcLong, srcLong[ i ], i + 1, onEvaluate ) !== -1 )
      length--;

      if( length === dstLong.length )
      return dstLong;

      result = _.longMakeUndefined( dstLong, length );

      for( let i = 0; i < dstLong.length; i++ )
      result[ i ] = dstLong[ i ]

      let offset = dstLong.length;
      for( let i = dstLong.length ; i < result.length && offset >= 0 ;  )
      {
        if( _.longLeftIndex( result, srcLong[ i - offset ], onEvaluate ) === -1 )
        {
          result[ i ] = srcLong[ i - offset ];
          i++;
        }
        else
        {
          offset--;
        }<commit_msg>--''--<commit_after>( function _gLong_s_() {

'use strict';

let _global = _global_;
let _ = _global_.wTools;
let Self = _global_.wTools;

//

let _ArrayIndexOf = Array.prototype.indexOf;
let _ArrayLastIndexOf = Array.prototype.lastIndexOf;
let _ArraySlice = Array.prototype.slice;
let _ArraySplice = Array.prototype.splice;
let _FunctionBind = Function.prototype.bind;
let _ObjectToString = Object.prototype.toString;
// let Object.hasOwnProperty = Object.hasOwnProperty;
let _ObjectPropertyIsEumerable = Object.propertyIsEnumerable;

// --
// long transformer
// --

/**
 * The routine longOnce() returns the {-dstLong-} with the duplicated elements removed.
 * The {-dstLong-} instance will be returned when possible, if not a new instance of the same type is created.
 *
 * @param { Long } dstLong - The source and destination Long.
 * @param { Function } onEvaluate - A callback function.
 *
 * @example
 * _.longOnce( [ 1, 1, 2, 'abc', 'abc', 4, true, true ] );
 * // returns [ 1, 2, 'abc', 4, true ]
 *
 * @example
 * _.longOnce( [ 1, 2, 3, 4, 5 ] );
 * // returns [ 1, 2, 3, 4, 5 ]
 *
 * @example
 * _.longOnce( [ { v : 1 },{ v : 1 }, { v : 1 } ], ( e ) => e.v );
 * // returns [ { v : 1 } ]
 *
 * @example
 * _.longOnce( [ { v : 1 },{ v : 1 }, { v : 1 } ], ( e ) => e.k );
 * // returns [ { v : 1 },{ v : 1 }, { v : 1 } ]
 *
 * @returns { Long } - If it is possible, returns the source Long without the duplicated elements.
 * Otherwise, returns copy of the source Long without the duplicated elements.
 * @function longOnce
 * @throws { Error } If passed arguments is less than one or more than two.
 * @throws { Error } If the first argument is not an long.
 * @throws { Error } If the second argument is not a Routine.
 * @namespace Tools
 */

function longOnce( dstLong, onEvaluate )
{
  _.assert( 1 <= arguments.length || arguments.length <= 2 );
  _.assert( _.longIs( dstLong ), 'Expects Long' );

  if( _.arrayIs( dstLong ) )
  return _.arrayRemoveDuplicates( dstLong, onEvaluate );

  if( !dstLong.length )
  return dstLong;

  let length = dstLong.length;

  for( let i = 0; i < dstLong.length; i++ )
  if( _.longLeftIndex( dstLong, dstLong[ i ], i+1, onEvaluate ) !== -1 )
  length--;

  if( length === dstLong.length )
  return dstLong;

  let result = _.longMakeUndefined( dstLong, length );
  result[ 0 ] = dstLong[ 0 ];

  let j = 1;
  for( let i = 1; i < dstLong.length && j < length; i++ )
  if( _.longRightIndex( result, dstLong[ i ], j-1, onEvaluate ) === -1 )
  result[ j++ ] = dstLong[ i ];

  _.assert( j === length );

  return result;
}

//

function longOnce_( dstLong, srcLong, onEvaluate )
{
  _.assert( dstLong === null || _.longIs( dstLong ), 'Expects Long' );

  if( dstLong === null )
  {
    if( _.longIs( srcLong ) )
    dstLong = _.longMakeUndefined( srcLong, 0 );
    else
    return [];
  }
  if( arguments.length === 1 )
  {
    srcLong = dstLong;
  }
  else if( arguments.length === 2 )
  {
    if( _.routineIs( srcLong ) )
    {
      onEvaluate = arguments[ 1 ];
      srcLong = arguments[ 0 ];
    }
  }
  else if( arguments.length !== 3 )
  _.assert( 0 );

  _.assert( _.longIs( srcLong ) );

  let result;

  if( dstLong === srcLong )
  {
    if( !dstLong.length )
    return dstLong;

    if( _.arrayIs( dstLong ) )
    return _.arrayRemoveDuplicates( dstLong, onEvaluate );

    let length = dstLong.length;

    for( let i = 0; i < dstLong.length; i++ )
    if( _.longLeftIndex( dstLong, dstLong[ i ], i + 1, onEvaluate ) !== -1 )
    length--;

    if( length === dstLong.length )
    return dstLong;

    result = _.longMakeUndefined( dstLong, length );
    result[ 0 ] = dstLong[ 0 ];

    let j = 1;
    for( let i = 1; i < dstLong.length && j < length; i++ )
    if( _.longRightIndex( result, dstLong[ i ], j - 1, onEvaluate ) === -1 )
    result[ j++ ] = dstLong[ i ];

    _.assert( j === length );
  }
  else
  {
    if( _.arrayIs( dstLong ) )
    {
      result = _.arrayAppendArrayOnce( dstLong, srcLong, onEvaluate );
    }
    else
    {
      let length = srcLong.length + dstLong.length;

      for( let i = 0; i < srcLong.length; i++ )
      if( _.longLeftIndex( dstLong, srcLong[ i ], onEvaluate ) !== -1 || _.longLeftIndex( srcLong, srcLong[ i ], i + 1, onEvaluate ) !== -1 )
      length--;

      if( length === dstLong.length )
      return dstLong;

      result = _.longMakeUndefined( dstLong, length );

      for( let i = 0; i < dstLong.length; i++ )
      result[ i ] = dstLong[ i ]

      let offset = dstLong.length;
      for( let i = dstLong.length ; i < result.length && offset >= -result.length ;  )
      {
        if( _.longLeftIndex( result, srcLong[ i - offset ], onEvaluate ) === -1 )
        {
          result[ i ] = srcLong[ i - offset ];
          i++;
        }
        else
        {
          offset--;
        }
{'fraction_non_alphanumeric': 0.15459841864336246, 'fraction_numerical': 0.01258843112775697, 'mean_word_length': 2.507114191900766, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 9, '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': '4648724', 'n_tokens_mistral': 3375, 'n_tokens_neox': 3180, 'n_words': 1006}