Trait indxvec::Mutops

source ·
pub trait Mutops<T> {
    // Required methods
    fn part_binary(self, rng: &Range<usize>, bitmask: u64) -> usize
       where T: Copy,
             u64: From<T>;
    fn mutrevs(self);
    fn mutsorttwo(self, i0: usize, i1: usize) -> bool
       where T: PartialOrd;
    fn mutsortthree(self, i0: usize, i1: usize, i2: usize)
       where T: PartialOrd;
    fn muthashsort(self, quantify: impl Copy + Fn(&T) -> f64)
       where T: PartialOrd + Clone;
    fn muthashsortslice(
        self,
        i: usize,
        n: usize,
        min: f64,
        max: f64,
        quantify: impl Copy + Fn(&T) -> f64
    )
       where T: PartialOrd + Clone;
    fn mutisort<F>(self, rng: Range<usize>, c: F)
       where T: Copy,
             F: Fn(&T, &T) -> Ordering;

    // Provided method
    fn part(
        s: &mut [&T],
        rng: &Range<usize>,
        c: &mut impl FnMut(&T, &T) -> Ordering
    ) -> (usize, usize) { ... }
}
Expand description

Mutable Operators on &mut[T]

Required Methods§

source

fn part_binary(self, rng: &Range<usize>, bitmask: u64) -> usize
where T: Copy, u64: From<T>,

partitions by bitmask

source

fn mutrevs(self)

mutable reversal, general utility

source

fn mutsorttwo(self, i0: usize, i1: usize) -> bool
where T: PartialOrd,

utility that mutably swaps two indexed items into ascending order

source

fn mutsortthree(self, i0: usize, i1: usize, i2: usize)
where T: PartialOrd,

utility that mutably bubble sorts three indexed items into ascending order

source

fn muthashsort(self, quantify: impl Copy + Fn(&T) -> f64)
where T: PartialOrd + Clone,

Possibly the fastest sort for long lists. Wrapper for muthashsortslice.

source

fn muthashsortslice( self, i: usize, n: usize, min: f64, max: f64, quantify: impl Copy + Fn(&T) -> f64 )
where T: PartialOrd + Clone,

Sorts n items from i in self. Used by muthashsort.

source

fn mutisort<F>(self, rng: Range<usize>, c: F)
where T: Copy, F: Fn(&T, &T) -> Ordering,

Mutable insert logsort. Pass in reversed comparator c for descending sort

Provided Methods§

source

fn part( s: &mut [&T], rng: &Range<usize>, c: &mut impl FnMut(&T, &T) -> Ordering ) -> (usize, usize)

Associated method part partitions s: &mut [&T] within range rng, using comparator c.
Suitable pivot should be selected and placed in s[rng.start].
Returns the boundaries of the rearranged partitions, (eqstart,gtstart), where
rng.start..eqstart (may be empty) contains references to items lesser than the pivot,
gtstart-eqstart is the number (>= 1) of items equal to the pivot (contains undefined references)
gtstart..rng.end (may be empty) contains references to items greater than the pivot.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> Mutops<T> for &mut [T]

source§

fn part_binary(self, rng: &Range<usize>, bitmask: u64) -> usize
where T: Copy, u64: From<T>,

Partitions s: &mut [u64] within range rng, using bitmask.
Returns the boundary of the rearranged partitions gtstart, where
rng.start..gtstart (may be empty) contains items with zero bit(s) corresponding to bitmask,
gtstart..rng.end (may be empty) contains items with one (or more) set bit(s).

source§

fn mutrevs(self)

Destructive reversal by swapping

source§

fn mutsorttwo(self, i0: usize, i1: usize) -> bool
where T: PartialOrd,

sort two slice items if they are out of ascending order

source§

fn mutsortthree(self, i0: usize, i1: usize, i2: usize)
where T: PartialOrd,

sort three slice items if they are out of ascending order

source§

fn muthashsortslice( self, i: usize, n: usize, fmin: f64, fmax: f64, quantify: impl Copy + Fn(&T) -> f64 )
where T: PartialOrd + Clone,

Requires [min,max], the data range, that must enclose all its values. If the range is known in advance, use this in preference to muthashsort to save finding it

source§

fn muthashsort(self, quantify: impl Copy + Fn(&T) -> f64)
where T: PartialOrd + Clone,

N recursive hash sort. Sorts mutable first argument in place Takes closure quantify for converting user type T to f64

source§

fn mutisort<F>(self, rng: Range<usize>, c: F)
where T: Copy, F: Fn(&T, &T) -> Ordering,

Mutable insert logsort. Pass in reversed comparator c for descending sort

Implementors§