public void addValue ( double value ) { if ( dataSetSize == dataSet . length ) { // Increase the capacity of the array. int newLength = ( int ) ( GROWTH_RATE * dataSetSize ) ; double [ ] newDataSet = new double [ newLength ] ; System . arraycopy ( dataSet , 0 , newDataSet , 0 , dataSetSize ) ; dataSet = newDataSet ; } dataSet [ dataSetSize ] = value ; updateStatsWithNewValue ( value ) ; ++ dataSetSize ; }
Adds a single value to the data set and updates any statistics that are calculated cumulatively .