Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
std::partition is an STL algorithm to partition elements in a container by a certain predicate. For example, in the code shown below, a std::vector is partitioned into primes and non-primes. Note that the order of the non-primes has changed. If the ordering must remain, use std::stable_partition.
#include <algorithm> |
Screen output:
Primes: 1 2 3 7 5 |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.