Skip to content

Commit

Permalink
added elementsAreNonDescending() validator function
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelGunawan committed Oct 13, 2024
1 parent ec7c296 commit 2161c64
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/tcframe/validator/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@ bool eachElementIsBetween(const vector<T>& v, T minVal, T maxVal) {
return true;
}

template<typename T>
bool elementsAreNonDescending(const vector<T>& v) {
for (std::size_t i = 1; i < v.size(); ++i) {
if (v[i - 1] > v[i]) {
return false;
}
}
return true;
}

}

0 comments on commit 2161c64

Please sign in to comment.