This function is found in header file %u2018boost/algorithm/cxx11/is_partitioned.hpp%u2019
It analyzes and test whether given sequence is partitioned as per given predicate or not.
partition here means that all items in the sequence that satisfy predicate are at beginning.
is_partitioned come in two forms,first one takes two iterators to define the range.The second form takes a single range
parameter,and uses Boost Range to traverse it.
Syntax: bool is_partitioned(inputiterator first,inputiterator last,Predicate p)
This function take parameters as:
1) first: It specifies the input iterators to the initial positions in a sequence.
2) second: It specifies the input iterators to the final positions in a sequence.
3) p: It specifies the comparison predicate if specified.
4) r: It specifies the given range completely.
The function is_partitioned returns true if the items in the sequence are partitioned according to their ability to satisfy
the predicate else returns false.
//Enter Your Code Here...
#include <bits/stdc++.h>
#include <boost/algorithm/cxx11/is_partitioned.hpp>
using
namespace
std;
//function to check whether
//Given function is odd or not
bool
oddCheck(
int
j)
{
return
j % 2 == 1;
}
int
main()
{
//sequence declaration with
int
d[] = { 1, 2, 7, 8, 10 };
bool
result
= boost::algorithm::is_partitioned(d, oddCheck);
//Condition to check
if
(result == 1)
cout <<
"Sequence is partitioned"
;
else
cout <<
"Sequence is not partitioned"
;
return
0;
}
OUTPUT: Sequence is not partitioned
Comments