diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-03-06 00:07:06 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-03-06 15:12:36 +0000 |
| commit | fb2fb3811fb28ffa1dfa69f471260ea2e47996f7 (patch) | |
| tree | 861a7ba4439c0a3756e90efbc70641d6aaedac27 /src/utils.hh | |
| parent | 72b6340b35af1b85f9bfc25e6092101654eba84b (diff) | |
Tweak useage of skip_while and move the functions in utils.hh
Diffstat (limited to 'src/utils.hh')
| -rw-r--r-- | src/utils.hh | 16 |
1 files changed, 16 insertions, 0 deletions
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<typename Iterator, typename EndIterator, typename T> +bool skip_while(Iterator& it, const EndIterator& end, T condition) +{ + while (it != end and condition(*it)) + ++it; + return it != end; +} + +template<typename Iterator, typename BeginIterator, typename T> +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 |
