src/Product.h
raw| 1 | #ifndef FREEBAYES_PRODUCT_H |
| 2 | #define FREEBAYES_PRODUCT_H |
| 3 | |
| 4 | #include <vector> |
| 5 | |
| 6 | template <class T> |
| 7 | T product(const std::vector<T>& v) { |
| 8 | if (v.size() > 0) { |
| 9 | T result = 1; |
| 10 | for (typename std::vector<T>::const_iterator i = v.begin(); i != v.end(); ++i) { |
| 11 | result *= *i; |
| 12 | } |
| 13 | return result; |
| 14 | } else { |
| 15 | return 0; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | #endif |