diff --git a/octa/algorithm.h b/octa/algorithm.h index f73ff97..324e195 100644 --- a/octa/algorithm.h +++ b/octa/algorithm.h @@ -24,6 +24,14 @@ namespace octa { return ret; } + template + bool is_partitioned(R range, P pred) { + for (; !range.empty() && pred(range.first()); range.pop_first()); + for (; !range.empty(); range.pop_first()) + if (pred(range.first())) return false; + return true; + } + template void insertion_sort(R range, C compare) { size_t rlen = range.length();