range: comment sections

This commit is contained in:
Danny Robson 2015-02-20 20:40:01 +11:00
parent bf3a6f2be7
commit f0ea25ed97

View File

@ -42,24 +42,28 @@ range<T>::range (T _min, T _max):
{ sanity (); } { sanity (); }
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
bool bool
range<T>::contains (T val) const range<T>::contains (T val) const
{ return val >= min && val <= max; } { return val >= min && val <= max; }
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
bool bool
range<T>::contains (const range <T> &r) const range<T>::contains (const range <T> &r) const
{ return r.min >= min && r.max <= max; } { return r.min >= min && r.max <= max; }
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
void void
range<T>::sanity (void) const range<T>::sanity (void) const
{ CHECK (min <= max); } { CHECK (min <= max); }
//-----------------------------------------------------------------------------
namespace util { namespace util {
template <> template <>
void void
@ -71,12 +75,14 @@ namespace util {
} }
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
T T
range<T>::clamp (T val) const range<T>::clamp (T val) const
{ return std::max (min, std::min (val, max)); } { return std::max (min, std::min (val, max)); }
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
void void
range<T>::expand (T val) { range<T>::expand (T val) {
@ -87,6 +93,7 @@ range<T>::expand (T val) {
} }
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
range<T>& range<T>&
range<T>::operator*= (T val) { range<T>::operator*= (T val) {
@ -97,6 +104,7 @@ range<T>::operator*= (T val) {
} }
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
range<T> range<T>
range<T>::operator* (T val) const { range<T>::operator* (T val) const {
@ -104,6 +112,7 @@ range<T>::operator* (T val) const {
} }
//-----------------------------------------------------------------------------
namespace util { namespace util {
template <> template <>
double double
@ -120,6 +129,8 @@ namespace util {
} }
} }
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
T T
range<T>::random (void) const { range<T>::random (void) const {
@ -127,6 +138,7 @@ range<T>::random (void) const {
} }
//-----------------------------------------------------------------------------
namespace util { namespace util {
template <> template <>
bool bool
@ -143,12 +155,14 @@ namespace util {
} }
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
bool bool
range<T>::operator ==(const range<T> &rhs) const range<T>::operator ==(const range<T> &rhs) const
{ return min == rhs.min && max == rhs.max; } { return min == rhs.min && max == rhs.max; }
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
const range<T> const range<T>
range<T>::UNLIMITED (numeric_limits<T>::has_infinity ? -numeric_limits<T>::infinity () : range<T>::UNLIMITED (numeric_limits<T>::has_infinity ? -numeric_limits<T>::infinity () :
@ -156,17 +170,20 @@ range<T>::UNLIMITED (numeric_limits<T>::has_infinity ? -numeric_limits<T>::infin
numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity () : numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity () :
numeric_limits<T>::max ()); numeric_limits<T>::max ());
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
const range<T> const range<T>
range<T>::MAX (numeric_limits<T>::lowest (), range<T>::MAX (numeric_limits<T>::lowest (),
numeric_limits<T>::max ()); numeric_limits<T>::max ());
//-----------------------------------------------------------------------------
template <typename T> template <typename T>
const range<T> const range<T>
range<T>::UNIT (0.0, 1.0); range<T>::UNIT (0.0, 1.0);
//-----------------------------------------------------------------------------
namespace util { namespace util {
template struct range<double>; template struct range<double>;
template struct range<float>; template struct range<float>;