From fb2fb3811fb28ffa1dfa69f471260ea2e47996f7 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 6 Mar 2016 00:07:06 +0000 Subject: Tweak useage of skip_while and move the functions in utils.hh --- src/utils.hh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/utils.hh') diff --git a/src/utils.hh b/src/utils.hh index 68acc296..516d530c 100644 --- a/src/utils.hh +++ b/src/utils.hh @@ -99,6 +99,22 @@ const T& clamp(const T& val, const T& min, const T& max) return (val < min ? min : (val > max ? max : val)); } +template +bool skip_while(Iterator& it, const EndIterator& end, T condition) +{ + while (it != end and condition(*it)) + ++it; + return it != end; +} + +template +bool skip_while_reverse(Iterator& it, const BeginIterator& begin, T condition) +{ + while (it != begin and condition(*it)) + --it; + return condition(*it); +} + } #endif // utils_hh_INCLUDED -- cgit v1.2.3