Change range::includes to range::contains

Contains is more descriptive (of the actual implementation) as it
implies the entire argument is within the range. Includes should also be
provided at some point.
This commit is contained in:
Danny Robson 2011-07-29 17:38:07 +10:00
parent b642590ab2
commit 1fc1dd4134
3 changed files with 8 additions and 6 deletions

View File

@ -249,8 +249,8 @@ matrix::is_magic (void) const {
unsigned int sum1 = 0, sum2 = 0;
for (unsigned int j = 0; j < m_columns; ++j) {
if (!numbers.includes ((*this)[i][j]) ||
!numbers.includes ((*this)[j][i]))
if (!numbers.contains ((*this)[i][j]) ||
!numbers.contains ((*this)[j][i]))
return false;
sum1 += (*this)[i][j];

View File

@ -43,13 +43,13 @@ range<T>::range (T _min, T _max):
template <typename T>
bool
range<T>::includes (T val) const
range<T>::contains (T val) const
{ return val >= min && val <= max; }
template <typename T>
bool
range<T>::includes (const range <T> &r) const
range<T>::contains (const range <T> &r) const
{ return r.min >= min && r.max <= max; }

View File

@ -37,9 +37,11 @@ struct range {
range (T _min, T _max);
/// Check whether value falls within this range (inclusive)
bool includes (T val) const;
bool contains (T val) const;
/// Check whether a range falls completely within (inclusive) this range
bool includes (const range <T> &r) const;
bool contains (const range <T> &r) const;
/// Check whether a range falls partially within (inclusive) this range
//bool includes (const range <T> &r) const;
/// Return the closest number that falls within the range.
T clamp (T val) const;