/* DataSet.h Specification of a DataSet Class [Taken from requirements .....] Author: J Morris Date Last Modified: 17 October, 1997 */ typedef struct dataset *DataSet; DataSet ConsDataSet( int max_items ); /* Construct a new data set - max_items is the maximum number of points in the data set Pre-cond: max_items > 0 Post-cond: returns a newly constructed DataSet or NULL if insufficient memory */ int DeleteDataSet( DataSet ds ); /* Delete a data set. Pre-cond: ds is a valid DataSet Post-cond: space used by ds has been freed returns TRUE if no errors, FALSE on error */ int ClearDataSet( DataSet ds ); /* Reset the DataSet ds (allows the same space to be re-used, without free/malloc overhead) Pre-cond: ds is a valid DataSet Post-cond: entries in ds have all been cleared, */ int TotalPoints( DataSet ds ); /* Count total points in the data set Pre-cond: ds is a valid DataSet Post-cond: returns count of points added to the DataSet */ int AddDatum( DataSet ds, double x ); /* Add a new data point to the data set Pre-cond: ds is a valid DataSet Post-cond: TotalPoints( h ) = old TotalPoints( h ) + 1 */ double SampleMean( DataSet ds, int *num_below ); /* Return the sample mean and the number of items below the mean in the int to which num_below points Pre-cond: ds is a valid DataSet && num_below is a valid pointer Post-cond: returns the mean of the data points added so far */ double Maximum( DataSet ds, int *index ); double Minimum( DataSet ds, int *index ); /* Return the maximum/minimum value in the data set Pre-cond: ds is a valid DataSet index != NULL Post-cond: returns the maximum/minimum index points to the 'position' of the maximum/minimum */