42#ifndef UFO_CONTAINER_TREE_PREDICATE_PREDICATE_INTERVAL_HPP
43#define UFO_CONTAINER_TREE_PREDICATE_PREDICATE_INTERVAL_HPP
46#include <ufo/utility/type_traits.hpp>
57template <
class T,
bool Negated>
59 using value_type = T::value_type;
63 constexpr PredicateInterval(value_type value) noexcept : min(value), max(value) {}
70 value_type
min = std::numeric_limits<value_type>::lowest();
71 value_type
max = std::numeric_limits<value_type>::max();
74template <
class T,
bool Negated>
81template <
class T,
bool Negated>
82[[nodiscard]]
constexpr PredicateInterval<T, Negated> operator==(
83 [[maybe_unused]] PredicateInterval<T, Negated>
const& p,
84 typename T::value_type
const& v)
noexcept
86 return PredicateInterval<T, Negated>(v, v);
89template <
class T,
bool Negated>
90[[nodiscard]]
constexpr PredicateInterval<T, Negated> operator==(
91 typename T::value_type
const& v,
92 [[maybe_unused]] PredicateInterval<T, Negated>
const& p)
noexcept
94 return PredicateInterval<T, Negated>(v, v);
97template <
class T,
bool Negated>
98[[nodiscard]]
constexpr PredicateInterval<T, true> operator!=(
99 [[maybe_unused]] PredicateInterval<T, Negated>
const& p,
100 typename T::value_type
const& v)
noexcept
102 return PredicateInterval<T, true>(v, v);
105template <
class T,
bool Negated>
106[[nodiscard]]
constexpr PredicateInterval<T, true> operator!=(
107 typename T::value_type
const& v,
108 [[maybe_unused]] PredicateInterval<T, Negated>
const& p)
noexcept
110 return PredicateInterval<T, true>(v, v);
113template <
class T,
bool Negated>
114[[nodiscard]]
constexpr PredicateInterval<T, Negated> operator<=(
115 PredicateInterval<T, Negated>
const& p,
typename T::value_type
const& v)
noexcept
117 return PredicateInterval<T, Negated>(std::min(p.min, v), v);
120template <
class T,
bool Negated>
121[[nodiscard]]
constexpr PredicateInterval<T, Negated> operator<=(
122 typename T::value_type
const& v, PredicateInterval<T, Negated>
const& p)
noexcept
124 return PredicateInterval<T, Negated>(v, std::max(p.max, v));
127template <
class T,
bool Negated>
128[[nodiscard]]
constexpr PredicateInterval<T, Negated> operator<(
129 PredicateInterval<T, Negated>
const& p,
typename T::value_type
const& v)
noexcept
131 using value_type =
typename T::value_type;
132 if constexpr (std::floating_point<value_type>) {
133 return p <= std::nextafter(v, std::numeric_limits<value_type>::lowest());
135 assert(v > v - value_type(1));
136 return p <= v - value_type(1);
140template <
class T,
bool Negated>
141[[nodiscard]]
constexpr PredicateInterval<T, Negated> operator<(
142 typename T::value_type
const& v, PredicateInterval<T, Negated>
const& p)
noexcept
144 using value_type =
typename T::value_type;
145 if constexpr (std::floating_point<value_type>) {
146 return std::nextafter(v, std::numeric_limits<value_type>::max()) <= p;
148 assert(v < v + value_type(1));
149 return v + value_type(1) <= p;
153template <
class T,
bool Negated>
154[[nodiscard]]
constexpr PredicateInterval<T, Negated> operator>=(
155 PredicateInterval<T, Negated>
const& p,
typename T::value_type
const& v)
noexcept
160template <
class T,
bool Negated>
161[[nodiscard]]
constexpr PredicateInterval<T, Negated> operator>=(
162 typename T::value_type
const& v, PredicateInterval<T, Negated>
const& p)
noexcept
167template <
class T,
bool Negated>
168[[nodiscard]]
constexpr PredicateInterval<T, Negated> operator>(
169 PredicateInterval<T, Negated>
const& p,
typename T::value_type
const& v)
noexcept
174template <
class T,
bool Negated>
175[[nodiscard]]
constexpr PredicateInterval<T, Negated> operator>(
176 typename T::value_type
const& v, PredicateInterval<T, Negated>
const& p)
noexcept
constexpr Vec< Geometry::dimension(), typename Geometry::value_type > max(Geometry const &g)
Returns the maximum coordinate of the minimum spanning axis-aligned bounding box of a geometry.
constexpr Vec< Geometry::dimension(), typename Geometry::value_type > min(Geometry const &g)
Returns the minimum coordinate of the minimum spanning axis-aligned bounding box of a geometry.