4 #include <fmt/format.h>
18 explicit Interval(TYPE lower_value, TYPE upper_value)
19 : lower_{lower_value}, upper_{upper_value} {}
23 TYPE
lower() const noexcept {
return lower_; }
27 TYPE
upper() const noexcept {
return upper_; }
31 TYPE
length() const noexcept {
return upper_ - lower_; }
37 if (lower_ < upper_) {
38 return lower_ <= value && value <= upper_;
41 return lower_ >= value && value >= upper_;
53 std::string
to_string() const noexcept {
return fmt::format(
"{}-{}", lower_, upper_); }
80 const std::string_view delims =
"-");
88 const std::string_view delims =
"-");
96 const std::string_view delims =
"-");
Numeric interval representation data type.
Definition: interval.h:10
auto operator<=>(const Interval< TYPE > &rhs) const =default
Compare two Interval instances.
bool contains(Interval< TYPE > &other) const noexcept
Determines whether an Interval is inside this instance interval.
Definition: interval.h:47
std::string to_string() const noexcept
Convert this instance to a string representation.
Definition: interval.h:53
TYPE upper() const noexcept
Gets the interval upper bound.
Definition: interval.h:27
TYPE length() const noexcept
Gets the interval length.
Definition: interval.h:31
Interval()=default
Initialises a new instance of the Interval class.
TYPE lower() const noexcept
Gets the interval lower bound.
Definition: interval.h:23
Interval(TYPE lower_value, TYPE upper_value)
Initialises a new instance of the Interval class.
Definition: interval.h:18
bool contains(TYPE value) const noexcept
Determines whether a value is in the Interval.
Definition: interval.h:36
Top-level namespace for Health-GPS Core C++ API.
Definition: analysis.h:7
FloatInterval parse_float_interval(const std::string_view &value, const std::string_view delims)
Converts the string representation to its FloatInterval equivalent.
Definition: interval.cpp:16
DoubleInterval parse_double_interval(const std::string_view &value, const std::string_view delims)
Converts the string representation to its DoubleInterval equivalent.
Definition: interval.cpp:26
@ other
Common diseases excluding cancers.
IntegerInterval parse_integer_interval(const std::string_view &value, const std::string_view delims)
Converts the string representation to its IntegerInterval equivalent.
Definition: interval.cpp:5