<commit_before>// Copyright 2002-2014, University of Colorado Boulder

/**
 * XY Data Series
 *
 * @author <NAME>
 */
define( function( require ) {
  'use strict';

  var inherit = require( 'PHET_CORE/inherit' );
  var Events = require( 'AXON/Events' );

  function XYDataSeries( options ) {

    options = _.extend( {
      color: 'black',
      maxPoints: 1000
    }, options );

    this.color = options.color; // @public
    this.maxPoints = options.maxPoints; // @private
    this.listeners = []; // @private

    //this.xPoints = [];
    this.xPoints = new Array( options.maxPoints ); // @private
    //this.yPoints = [];
    this.yPoints = new Array( options.maxPoints ); // @private

    this.dataSeriesLength = 0; // @private, index to next available slot

    Events.call( this );
  }

  return inherit( Events, XYDataSeries, {

    addDataSeriesListener: function( listener ) {
      this.listeners.push( listener );
    },

    removeDataSeriesListener: function( listener ) {
      var index = this.listeners.indexOf( listener );
      if ( index !== -1 ) {
        this.listeners.splice( index, 1 );
      }
    },

    addPoint: function( x, y ) {

      // store the data
      this.xPoints[ this.dataSeriesLength ] = x;
      this.yPoints[ this.dataSeriesLength ] = y;

      // notify listeners - note that the previous data series values can be undefined in the notification
      for ( var i = 0; i < this.listeners.length; i++ ) {
        this.listeners[ i ]( x, y, this.xPoints[ this.dataSeriesLength - 1 ], this.yPoints[ this.dataSeriesLength - 1 ] );
      }

      // point to the next slot
      this.dataSeriesLength++;
      assert && assert( this.dataSeriesLength < this.maxPoints, 'Capacity of data series exceeded' );
    },

    clear: function() {
      this.dataSeriesLength = 0;
      this.trigger( 'cleared' );
    },

    getX: function( index ) {
      if ( index > this.dataSeriesLength - 1 ) {
        throw new Error( "No Data Point Exist at this index " + index );
      }
      return this.xPoints[ index ];
    },

    getY: function( index ) {
      if ( index > this.dataSeriesLength - 1 ) {
        throw new Error( "No Data Point Exist at this index " + index );
      }
      return this.yPoints[ index ];
    },

    /**<commit_msg>Fixed lint issues, see https://github.com/phetsims/chipper/issues/235<commit_after>// Copyright 2002-2014, University of Colorado Boulder

/**
 * XY Data Series
 *
 * @author <NAME>
 */
define( function( require ) {
  'use strict';

  var inherit = require( 'PHET_CORE/inherit' );
  var Events = require( 'AXON/Events' );

  function XYDataSeries( options ) {

    options = _.extend( {
      color: 'black',
      maxPoints: 1000
    }, options );

    this.color = options.color; // @public
    this.maxPoints = options.maxPoints; // @private
    this.listeners = []; // @private

    //this.xPoints = [];
    this.xPoints = new Array( options.maxPoints ); // @private
    //this.yPoints = [];
    this.yPoints = new Array( options.maxPoints ); // @private

    this.dataSeriesLength = 0; // @private, index to next available slot

    Events.call( this );
  }

  return inherit( Events, XYDataSeries, {

    addDataSeriesListener: function( listener ) {
      this.listeners.push( listener );
    },

    removeDataSeriesListener: function( listener ) {
      var index = this.listeners.indexOf( listener );
      if ( index !== -1 ) {
        this.listeners.splice( index, 1 );
      }
    },

    addPoint: function( x, y ) {

      // store the data
      this.xPoints[ this.dataSeriesLength ] = x;
      this.yPoints[ this.dataSeriesLength ] = y;

      // notify listeners - note that the previous data series values can be undefined in the notification
      for ( var i = 0; i < this.listeners.length; i++ ) {
        this.listeners[ i ]( x, y, this.xPoints[ this.dataSeriesLength - 1 ], this.yPoints[ this.dataSeriesLength - 1 ] );
      }

      // point to the next slot
      this.dataSeriesLength++;
      assert && assert( this.dataSeriesLength < this.maxPoints, 'Capacity of data series exceeded' );
    },

    clear: function() {
      this.dataSeriesLength = 0;
      this.trigger( 'cleared' );
    },

    getX: function( index ) {
      if ( index > this.dataSeriesLength - 1 ) {
        throw new Error( 'No Data Point Exist at this index ' + index );
      }
      return this.xPoints[ index ];
    },

    getY: function( index ) {
      if ( index > this.dataSeriesLength - 1 ) {
        throw new Error( 'No Data Point Exist at this index ' + index );
      }
      return this.yPoints[ index ];
    },

    /**
{'fraction_non_alphanumeric': 0.13095238095238096, 'fraction_numerical': 0.00974025974025974, 'mean_word_length': 2.35828488372093, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, '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': '305898', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1357, 'n_words': 394}