HIBF 1.0.0-rc.1
All Classes Namespaces Files Functions Variables Typedefs Friends Macros Modules Pages Concepts
subtract_empty_bins.hpp
1// SPDX-FileCopyrightText: 2006-2025, Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2025, Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
5#pragma once
6
7#include <algorithm> // for clamp
8#include <cstddef> // for size_t
9
10#include <hibf/platform.hpp>
11
12namespace seqan::hibf
13{
14
21[[nodiscard]] constexpr size_t subtract_empty_bins(size_t const tmax, double const fraction) noexcept
22{
23 // There must be at least 2 technical bins available without empty bins.
24 // Otherwise, there would only ever be one technical bin available.
25 if (fraction == 0.0 || tmax <= 2u)
26 return tmax;
27
28 size_t const number_of_empty_bins = std::clamp<size_t>(tmax * fraction, 1, tmax - 2);
29 return tmax - number_of_empty_bins;
30}
31
32} // namespace seqan::hibf
constexpr size_t subtract_empty_bins(size_t const tmax, double const fraction) noexcept
Returns the number of technical bins available for use.
Definition subtract_empty_bins.hpp:21
T is_base_of_v
Provides platform and dependency checks.