Expand description
- A tool to reorder an array by an index array inplace when the elements are not
CloneorCopy. - lock-free parallel implementation.
§Example
use index_permute::PermuteIndex;
let index = PermuteIndex::try_new(&[2, 0, 1
]).unwrap();
let mut data = vec![10, 20, 30];
index_permute::order_by_index_inplace(&mut data, index);
assert_eq!(data, vec![30, 10, 20]);Macros§
- cfg_
parallel - A macro to conditionally compile items based on the
parallelfeature.
Structs§
- Permute
Index - A struct to hold a permutation index.
The index must be unique and in the range of
0..len, wherelenis the length of the data to be permuted. This struct is used to ensure that the index is valid before performing any operations on the data. It can be created usingPermuteIndex::try_new, which checks the validity of the index. If the index is invalid, it returns aPermuteError::InvalidIndexerror. The index can be used to permute data using thetry_order_by_index_inplacefunction. The index length must match the data length, otherwise it returns aPermuteError::LengthMismatcherror. Theorder_by_index_inplacefunction is a convenience function that panics if the index is invalid or the lengths do not match.
Enums§
- Permute
Error - An error type for
PermuteIndexandtry_order_by_index_inplace.
Functions§
- order_
by_ index_ inplace - A convenience function that panics if the index is invalid or the lengths do not match.
It is recommended to use
try_order_by_index_inplacefor error handling. - try_
order_ by_ index_ inplace - Reorders the data in place according to the given index.
First create a
PermuteIndex, then, it reorders the data in place - try_
order_ by_ index_ parallel_ inplace parallel - Same as
try_order_by_index_parallel_inplace_with_threadsbut uses the number of available CPU cores. Only valid when featuresparallelis enabled. - try_
order_ by_ index_ parallel_ inplace_ with_ threads parallel - Only valid when features
parallelis enabled. A parallel version oftry_order_by_index_inplace.