Update of /cvsroot/quantproject/QuantProject/b1_ADT/Statistics
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24333/b1_ADT/Statistics
Modified Files:
BasicFunctions.cs
Log Message:
static public double GetMax( ICollection data )
has been added (it returns the max value of the given data collection)
Index: BasicFunctions.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Statistics/BasicFunctions.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** BasicFunctions.cs 30 Jul 2006 14:16:31 -0000 1.8
--- BasicFunctions.cs 24 Jun 2007 21:25:54 -0000 1.9
***************
*** 59,62 ****
--- 59,89 ----
return sum;
}
+ /// <summary>
+ /// Returns the max value of the given data
+ /// </summary>
+ /// <param name="data">each data item must be convertible to a double</param>
+ /// <returns></returns>
+ static public double GetMax( ICollection data )
+ {
+ if ( data.Count < 1 )
+ throw new Exception( "The data collection does not contain " +
+ "any value!" );
+ double max = Double.MinValue;
+ foreach( object obj in data )
+ {
+ double valueToBeCompared;
+ try
+ {
+ valueToBeCompared = Convert.ToDouble( obj );
+ }
+ catch
+ {
+ throw new Exception( "The data collection contains " +
+ "a data that cannot be converted to double!" );
+ }
+ max = Math.Max( max , valueToBeCompared );
+ }
+ return max;
+ }
static public double GetSum( ICollection data )
{
|