Standard C++ Library Class Reference

in the range[first, i), pred(*j) == true, and, for any iterator k in the range [i, last), pred(*j) ==
false.
Note that partition does not necessarily maintain the relative order of the elements that match
and elements that do not match the predicate. Use the algorithm stable_partition if relative
order is important.
Complexity
The partition algorithm does at most (last - first)/2 swaps, and applies the predicate exactly last
- first times.
Example
//
// prtition.cpp
//
#include <functional>
#include <deque>
#include <algorithm>
#include <iostream.h>
//
// Create a new predicate from unary_function.
//
template<class Arg>
class is_even : public unary_function<Arg, bool>
{
public:
bool operator()(const Arg& arg1) { return (arg1 % 2) == 0; }
};
int main ()
{
//
// Initialize a deque with an array of integers.
//
int init[10] = { 1,2,3,4,5,6,7,8,9,10 };
deque<int> d1(init+0, init+10);
deque<int> d2(init+0, init+10);
//
// Print out the original values.
//
cout << "Unpartitioned values: " << "\t\t";
copy(d1.begin(), d1.end(), ostream_iterator<int>(cout," "));
cout << endl;
//