Partitions a range in two using the given predicate.
Specifically, reorders the range r = [left, right) using swap such that all elements i for which predicate(i) is true come before all elements j for which predicate(j) returns false.
Performs r.length (if unstable or semistable) or * log(r.length) (if stable) evaluations of less and swap. The unstable version computes the minimum possible evaluations of swap (roughly half of those performed by the semistable version).
Parameters
predicate | The predicate to partition by. |
ss | The swapping strategy to employ. |
r | The random-access range to partition. |
Returns
The right part of
r after partitioning.
If ss == SwapStrategy.stable, partition preserves the relative ordering of all elements a, b in r for which predicate(a) == predicate(b). If ss == SwapStrategy.semistable, partition preserves the relative ordering of all elements a, b in the left part of r for which predicate(a) == predicate(b).