Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:09

0001 // Copyright 2019 Henry Schreiner
0002 //
0003 // Distributed under the Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt
0005 // or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_HISTOGRAM_ALGORITHM_EMPTY_HPP
0008 #define BOOST_HISTOGRAM_ALGORITHM_EMPTY_HPP
0009 
0010 #include <boost/histogram/fwd.hpp>
0011 #include <boost/histogram/indexed.hpp>
0012 
0013 namespace boost {
0014 namespace histogram {
0015 namespace algorithm {
0016 /** Check to see if all histogram cells are empty. Use coverage to include or
0017   exclude the underflow/overflow bins.
0018 
0019   This algorithm has O(N) complexity, where N is the number of cells.
0020 
0021   Returns true if all cells are empty, and false otherwise.
0022  */
0023 template <class A, class S>
0024 auto empty(const histogram<A, S>& h, coverage cov) {
0025   using value_type = typename histogram<A, S>::value_type;
0026   const value_type default_value = value_type();
0027   for (auto&& ind : indexed(h, cov)) {
0028     if (*ind != default_value) { return false; }
0029   }
0030   return true;
0031 }
0032 } // namespace algorithm
0033 } // namespace histogram
0034 } // namespace boost
0035 
0036 #endif