diff --git a/octa/algorithm.h b/octa/algorithm.h index 9771787..39ba176 100644 --- a/octa/algorithm.h +++ b/octa/algorithm.h @@ -196,6 +196,7 @@ namespace octa { return max_element(PointerRange(il.get(), il.get() + il.length())).first(); } + template inline T max(InitializerList il, C compare) { return max_element(PointerRange(il.get(), @@ -208,6 +209,27 @@ namespace octa { func(range.first()); return move(func); } + + template + bool all_of(R range, P pred) { + for (; !range.empty(); range.pop_first()) + if (!pred(range.first())) return false; + return true; + } + + template + bool any_of(R range, P pred) { + for (; !range.empty(); range.pop_first()) + if (pred(range.first())) return true; + return false; + } + + template + bool none_of(R range, P pred) { + for (; !range.empty(); range.pop_first()) + if (pred(range.first())) return false; + return true; + } } #endif \ No newline at end of file