Template Function ADS::dutchNationalFlag

Function Documentation

template<class T, class F>
std::pair<std::size_t, std::size_t> ADS::dutchNationalFlag(std::vector<T> &A, F &&colour, std::size_t *swaps = nullptr)

dutchNationalFlag(): the items of A by colour( x ), 0 then 1 then 2, with n reads of the colours and at most n swaps, counted in *swaps if it is given; ( i , j ) with A[ 0 .

. i ) of colour 0, A[ i .. j ) of colour 1 and A[ j .. n ) of colour 2

Pre:

colour( x ) is 0, 1 or 2

Post:

the colours in order (an audit)