21 #ifndef PLAYRHO_COMMON_INTERVAL_HPP
22 #define PLAYRHO_COMMON_INTERVAL_HPP
49 using limits = std::numeric_limits<value_type>;
56 return (limits::has_infinity)? -limits::infinity(): limits::lowest();
64 return (limits::has_infinity)? limits::infinity(): limits::max();
147 m_min = std::min(v,
GetMin());
148 m_max = std::max(v,
GetMax());
160 m_min = std::min(v.GetMin(),
GetMin());
161 m_max = std::max(v.GetMax(),
GetMax());
168 const auto min = std::max(v.GetMin(),
GetMin());
169 const auto max = std::min(v.GetMax(),
GetMax());
213 using pair_type = std::pair<value_type, value_type>;
231 template <
typename T>
234 return v.GetMax() - v.GetMin();
241 template <
typename T>
245 return (v.GetMin() + v.GetMax()) / 2;
250 template <
typename T>
253 const auto maxOfMins = std::max(a.GetMin(), b.GetMin());
254 const auto minOfMaxs = std::min(a.GetMax(), b.GetMax());
255 return minOfMaxs >= maxOfMins;
260 template <
typename T>
263 return a.Intersect(b);
267 template <
typename T>
274 template <
typename T>
281 template <
typename T>
291 template <
typename T>
294 return (a.GetMin() == b.GetMin()) && (a.GetMax() == b.GetMax());
301 template <
typename T>
317 template <
typename T>
320 return (lhs.GetMin() < rhs.GetMin()) ||
321 (lhs.GetMin() == rhs.GetMin() && lhs.GetMax() < rhs.GetMax());
329 template <
typename T>
332 return (lhs.GetMin() < rhs.GetMin()) ||
333 (lhs.GetMin() == rhs.GetMin() && lhs.GetMax() <= rhs.GetMax());
341 template <
typename T>
344 return (lhs.GetMin() > rhs.GetMin()) ||
345 (lhs.GetMin() == rhs.GetMin() && lhs.GetMax() > rhs.GetMax());
353 template <
typename T>
356 return (lhs.GetMin() > rhs.GetMin()) ||
357 (lhs.GetMin() == rhs.GetMin() && lhs.GetMax() >= rhs.GetMax());
361 template <
typename T>
364 return os <<
'{' << value.
GetMin() <<
"..." << value.
GetMax() <<
'}';
369 #endif // PLAYRHO_COMMON_INTERVAL_HPP