Elements
6.2
A C++ base framework for the Euclid Software.
|
This class has been created to demonstrate unit testing. More...
#include <UnitTestExample.h>
Public Member Functions | |
double | average (const std::vector< int > &v) |
Returns a particular version of the "average" of the vector values. More... | |
This class has been created to demonstrate unit testing.
Definition at line 40 of file UnitTestExample.h.
double Elements::Examples::UnitTestExample::average | ( | const std::vector< int > & | v | ) |
Returns a particular version of the "average" of the vector values.
This method computes the "average" as the median of the given values if there are more than 5 values. Otherwise, it returns the mean value instead of the median.
If an even number of numbers is given, the returned value is the mean of the two middle values.
v | The values to compute the "average" for |
Elements::Exception | If the given vector is empty |
Definition at line 35 of file UnitTestExample.cpp.
References std::accumulate(), std::vector< T >::begin(), std::vector< T >::end(), std::vector< T >::size(), and std::sort().