2012-04-01 13:15:09 +00:00
|
|
|
#ifndef SPROUT_ALGORITHM_IS_PARTITIONED_HPP
|
|
|
|
#define SPROUT_ALGORITHM_IS_PARTITIONED_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
2012-12-15 08:41:20 +00:00
|
|
|
#include <sprout/algorithm/none_of.hpp>
|
|
|
|
#include <sprout/algorithm/find_if_not.hpp>
|
2012-04-01 13:15:09 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
// 25.3.13 Partitions
|
2012-12-15 08:41:20 +00:00
|
|
|
//
|
|
|
|
// recursion depth:
|
|
|
|
// [first, last) is RandomAccessIterator -> O(log N)
|
|
|
|
// otherwise -> O(N)
|
|
|
|
//
|
2012-04-01 13:15:09 +00:00
|
|
|
template<typename InputIterator, typename Predicate>
|
2012-10-06 04:53:07 +00:00
|
|
|
inline SPROUT_CONSTEXPR bool
|
|
|
|
is_partitioned(InputIterator first, InputIterator last, Predicate pred) {
|
2012-12-15 08:41:20 +00:00
|
|
|
return sprout::none_of(sprout::find_if_not(first, last, pred), last, pred);
|
2012-04-01 13:15:09 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_ALGORITHM_IS_PARTITIONED_HPP
|