From 2161c64365d083f167e19b26429dac187f2df010 Mon Sep 17 00:00:00 2001 From: JoelGunawan <39652408+JoelGunawan@users.noreply.github.com> Date: Sun, 13 Oct 2024 11:25:16 +0700 Subject: [PATCH] added elementsAreNonDescending() validator function --- include/tcframe/validator/vector.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/tcframe/validator/vector.hpp b/include/tcframe/validator/vector.hpp index 25d5671..240a554 100644 --- a/include/tcframe/validator/vector.hpp +++ b/include/tcframe/validator/vector.hpp @@ -14,4 +14,14 @@ bool eachElementIsBetween(const vector& v, T minVal, T maxVal) { return true; } +template +bool elementsAreNonDescending(const vector& v) { + for (std::size_t i = 1; i < v.size(); ++i) { + if (v[i - 1] > v[i]) { + return false; + } + } + return true; +} + }