-
Notifications
You must be signed in to change notification settings - Fork 61
Description
A couple of useful functions would be nice to have:
sorted_indices
to get a collection of indices corresponding to a sorted permutation of the passed collection. Basically an equivalent tonumpy.argsort
.apply_permutation
to shuffle a collection according to a vector of indices, which would notably allow to apply back the result ofsorted_indices
to any collection. Basically an equivalent to Boost.Algorithmapply_permutation
.
Both of these algorithms somewhat intervene in the implementation of indirect_adapter
, so there shouldn't be any big technical difficulty from an implementation point of view.
However sorted_indices
would probably better be implemented as a sorter adapter, so that it could work with any sorter and with the flexibility of sorter_facade
. The biggest challenge is to modify most of the documentation to relax sorter adapter restrictions so that they don't have to produce sorters. Alternatively I can just give it the interface of a sorter adapter without mentioning it explicitly and shove it in <cpp-sort/utility>
without having to make a bigger change today.
apply_permutation
can surely use the Boost.Algorithm interface and live in <cpp-sort/utility>
without trying to be more than that.