(C++) CountNonZeroes
February 24, 2017 · View on GitHub
(C++) CountNonZeroes
CountNonZeroes is a math code snippet to count all non-zero elements in a container.
#include <algorithm> #include <vector> //From http://www.richelbilderbeek.nl/CppCountNonZeroes.htm int CountNonZeroes(const std::vector<double>& v) { return std::count_if( v.begin(), v.end(), std::bind2nd(std::not_equal_to<double>(),0.0)); }