Files CCore/inc/algon/Partition.h CCore/src/algon/Partition.cpp
Partition() is a classical partition algorithm like std::partition with slightly different arguments.
template <class Ran,class Pred> Ran Algon::Partition(Ran ptr,ulen len,Pred pred); // reorder such that pred(Range(ptr,len)) is 1,1,...,0,0,... template <class T,class Pred> ulen Algon::Partition(PtrLen<T> r,Pred pred) { return Dist(r.ptr,Partition(r.ptr,r.len,pred)); }
The first variant takes the base pointer of a range and the range length as arguments. The third argument is a predicate. The algorithm reorders the range in such a way, that elements which make the predicate true goes first and others goes after. The return value is the base pointer of the subrange with the second kind elements.
The second variant is applied to the usual object range, given as a PtrLen<T> object. The return value is the length of the first subrange.