From 1fc1dd41342d889caab010d485dd3269d2c4525e Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 29 Jul 2011 17:38:07 +1000 Subject: [PATCH] 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. --- matrix.cpp | 4 ++-- range.cpp | 4 ++-- range.hpp | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/matrix.cpp b/matrix.cpp index 61b54950..0a51a4fb 100644 --- a/matrix.cpp +++ b/matrix.cpp @@ -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]; diff --git a/range.cpp b/range.cpp index 0e83e68b..035dbea1 100644 --- a/range.cpp +++ b/range.cpp @@ -43,13 +43,13 @@ range::range (T _min, T _max): template bool -range::includes (T val) const +range::contains (T val) const { return val >= min && val <= max; } template bool -range::includes (const range &r) const +range::contains (const range &r) const { return r.min >= min && r.max <= max; } diff --git a/range.hpp b/range.hpp index 262d024e..baf882a1 100644 --- a/range.hpp +++ b/range.hpp @@ -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 &r) const; + bool contains (const range &r) const; + /// Check whether a range falls partially within (inclusive) this range + //bool includes (const range &r) const; /// Return the closest number that falls within the range. T clamp (T val) const;