Skip to content

FEATURE REQUEST: Add empty #241

@henryiii

Description

@henryiii

I would like an empty(coverage) function or method for histograms, something like this:

bh::empty(hist, bh::coverage::all);
// OR
hist. empty(bh::coverage::all);

It could look something like this:

template<class histogram_t>
bool empty(const histogram_t &h, bh::coverage cov) {
    using value_type = typename histogram_t::value_type;
    value_type zero = value_type();
    for(auto&& ind : bh::indexed(h, cov)) {
        if(*ind != zero) {
            return false;
        }
    }
    return true;
}

This should be faster than sum if the histogram is filled, and would be useful for checking to see if an item fell into the histogram (inner), or for checking to see if this was filled yet (all).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions