pub fn unique_optimized<T>(
a: &Array<T>,
axis: Option<usize>,
return_index: Option<bool>,
return_inverse: Option<bool>,
return_counts: Option<bool>,
) -> Result<UniqueResult<T>>Expand description
Optimized version of the unique function to find unique elements of an array.
This version includes several optimizations over the standard unique function:
- Parallel processing for large arrays
- Pre-allocated buffers to reduce memory allocations
- Early capacity estimation based on input size
- SIMD-friendly memory access patterns where possible
§Parameters
a- Input arrayaxis- Optional axis along which to find unique elementsreturn_index- If true, also return the indices of the first occurrencesreturn_inverse- If true, also return the indices to reconstruct the original arrayreturn_counts- If true, also return the counts of each unique value
§Returns
A UniqueResult struct containing some or all of:
- The unique values in the array (required)
- The indices of the first unique values (if return_index is true)
- The indices to reconstruct the original array (if return_inverse is true)
- The counts of each unique value (if return_counts is true)