
判断[_First,_Last)区间内的元素是否被分割,也就是所有符合_Pred()的元素都被置于所有不符合的元素之前

返回[_First,_Last)区间内中的第一个元素的位置,使用_Pred(elem1,elem2),在elem1小于elem2时返回true.
复杂度:is_partitioned():线性
partition_point():如果收到的是随机访问迭代器则为对数,否则为线性
使用方法:
template<typename T>
inline void PRINT_ELEMENTS(const T & coll, const string& optcstr = "")
{
cout << optcstr;
for (auto elem : coll)
{
cout << elem << ' ';
}
cout << endl;
}
int main()
{
vector<int> a{ 5,3,9,1,3,4,8,2,6 };
PRINT_ELEMENTS(a, "a: ");
auto isodd = [](int elem) {return elem % 2 == 1; };
if (is_partitioned(a.cbegin(), a.cend(), isodd))
{
cout << "a is partitioned" << endl;
auto pos = partition_point(a.cbegin(), a.cend(), isodd);
cout << "first even element: " << *pos << endl;
}
else
{
cout << "a is not partitioned" << endl;
}
}
