Skip to main content

unique_optimized

Function unique_optimized 

Source
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>>
where T: Clone + Hash + Eq + Debug + Zero + Send + Sync,
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 array
  • axis - Optional axis along which to find unique elements
  • return_index - If true, also return the indices of the first occurrences
  • return_inverse - If true, also return the indices to reconstruct the original array
  • return_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)