partition [C++ Reference]
Keywords: stl,algorithm,partition
Date: 2009-10-09T01:59:17-0700

[[partition]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## partition

Syntax:

        #include <algorithm>
        bidirectional_iterator partition( bidirectional_iterator start, bidirectional_iterator end, Predicate p );

The partition algorithm re-orders the elements in `[start,end)` such that the elements for which the predicate `p` returns true come before the elements for which `p` returns false.

In other words, partition uses `p` to divide the elements into two groups. The return value of partition is an iterator to the first element for which `p` returns false.

partition runs in linear time.

Related Topics: stable_partition

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •