Skip to main content

SortableData

Trait SortableData 

Source
pub trait SortableData<T: TotalCmp + Clone>: Data<T> + Sync {
    // Provided methods
    fn as_contiguous_slice(&self) -> Option<&[T]> { ... }
    fn argsort_unstable(&self, pool: Option<&ThreadPool>) -> Vec<usize> { ... }
}
Expand description

Marker trait: implementors of Data<T> that also support sorting.

The default argsort_unstable uses get_at for element access so no copy is needed regardless of memory layout. Implementors that can provide a contiguous &[T] should override as_contiguous_slice to enable a faster slice-based comparator that LLVM can optimize more aggressively.

Provided Methods§

Source

fn as_contiguous_slice(&self) -> Option<&[T]>

Return a contiguous slice if the data is laid out contiguously in memory, None otherwise. The default returns None.

Source

fn argsort_unstable(&self, pool: Option<&ThreadPool>) -> Vec<usize>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<F: TotalCmp + Float + TotalOrder + Clone + Sync, const N: usize> SortableData<F> for [F; N]

Source§

impl<F: TotalCmp + Float + TotalOrder + Clone + Sync> SortableData<F> for &[F]

Source§

impl<F: TotalCmp + Float + TotalOrder + Clone + Sync> SortableData<F> for Vec<F>

Source§

impl<F> SortableData<F> for ArrayView<'_, F, Ix1>
where F: TotalCmp + Float + TotalOrder + Clone + Sync,

Implementors§