pub trait Vecops<'a, T> {
Show 40 methods
// Required methods
fn ref_vec(self, rng: Range<usize>) -> Vec<&'a T>;
fn tof64(self) -> Vec<f64>
where T: Clone,
f64: From<T>;
fn maxt(self) -> T
where T: PartialOrd + Clone;
fn mint(self) -> T
where T: PartialOrd + Clone;
fn minmaxt(self) -> (T, T)
where T: PartialOrd + Clone;
fn minmax(self) -> MinMax<T>
where T: PartialOrd + Clone;
fn minmax_slice(self, i: usize, n: usize) -> MinMax<T>
where T: PartialOrd + Clone;
fn minmax_indexed(self, idx: &[usize], i: usize, n: usize) -> MinMax<T>
where T: PartialOrd + Clone;
fn revs(self) -> Vec<T>
where T: Clone;
fn sansrepeat(self) -> Vec<T>
where T: PartialEq + Clone;
fn member(self, m: T, forward: bool) -> Option<usize>
where T: PartialEq + Clone;
fn occurs(self, val: T) -> usize
where T: PartialOrd;
fn unite_unsorted(self, v: &[T]) -> Vec<T>
where T: Clone;
fn unite_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>
where T: PartialOrd + Clone;
fn intersect(self, v2: &[T]) -> Vec<T>
where T: PartialOrd + Clone;
fn intersect_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>
where T: PartialOrd + Clone;
fn diff(self, v2: &[T]) -> Vec<T>
where T: PartialOrd + Clone;
fn diff_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>
where T: PartialOrd + Clone;
fn partition(self, pivot: &T) -> (Vec<T>, Vec<T>, Vec<T>)
where T: PartialOrd + Clone;
fn partition_indexed(
self,
pivot: &T
) -> (Vec<usize>, Vec<usize>, Vec<usize>)
where T: PartialOrd + Clone;
fn binsearch(self, target: &T) -> Range<usize>
where T: PartialOrd + Copy;
fn binsearch_indexed(self, idx: &[usize], target: &T) -> Range<usize>
where T: PartialOrd + Copy;
fn merge(self, v2: &[T]) -> Vec<T>
where T: PartialOrd + Clone;
fn merge_indexed(
self,
idx1: &[usize],
v2: &[T],
idx2: &[usize]
) -> (Vec<T>, Vec<usize>)
where T: PartialOrd + Clone;
fn merge_indices(self, idx1: &[usize], idx2: &[usize]) -> Vec<usize>
where T: PartialOrd + Clone;
fn mergesort_indexed(self) -> Vec<usize>
where T: PartialOrd + Clone;
fn mergesortslice(self, i: usize, n: usize) -> Vec<usize>
where T: PartialOrd + Clone;
fn sortm(self, ascending: bool) -> Vec<T>
where T: PartialOrd + Clone;
fn rank(self, ascending: bool) -> Vec<usize>
where T: PartialOrd + Clone;
fn isorttwo(self, idx: &mut [usize], i0: usize, i1: usize)
where T: PartialOrd;
fn isortthree(self, idx: &mut [usize], i0: usize, i1: usize, i2: usize)
where T: PartialOrd;
fn hashsort_indexed(self, quantify: impl Copy + Fn(&T) -> f64) -> Vec<usize>
where T: PartialOrd + Clone;
fn hashsortslice(
self,
idx: &mut [usize],
i: usize,
n: usize,
min: f64,
max: f64,
quantify: impl Copy + Fn(&T) -> f64
)
where T: PartialOrd + Clone;
fn sorth(
self,
quantify: impl Copy + Fn(&T) -> f64,
ascending: bool
) -> Vec<T>
where T: PartialOrd + Clone;
fn smallest_k(&self, k: usize) -> BinaryHeap<&T>
where T: Ord;
fn biggest_k(&self, k: usize) -> BinaryHeap<Reverse<&T>>
where T: Ord;
fn isort_indexed<F>(self, rng: Range<usize>, c: F) -> Vec<usize>
where F: Fn(&T, &T) -> Ordering;
fn isort_refs<F>(self, rng: Range<usize>, c: F) -> Vec<&'a T>
where F: Fn(&T, &T) -> Ordering;
fn best_k<F>(self, k: usize, rng: Range<usize>, c: F) -> Vec<&'a T>
where F: Fn(&T, &T) -> Ordering;
// Provided method
fn deref_vec(v: &[&T], rng: Range<usize>) -> Vec<T>
where T: Clone { ... }
}
Expand description
Methods to manipulate generic Vecs and slices of type &[T]
Required Methods§
sourcefn ref_vec(self, rng: Range<usize>) -> Vec<&'a T>
fn ref_vec(self, rng: Range<usize>) -> Vec<&'a T>
Constructs ref wrapped Vec<&T>
from &[T] in rng
sourcefn maxt(self) -> Twhere
T: PartialOrd + Clone,
fn maxt(self) -> Twhere
T: PartialOrd + Clone,
Maximum value in self
sourcefn mint(self) -> Twhere
T: PartialOrd + Clone,
fn mint(self) -> Twhere
T: PartialOrd + Clone,
Minimum value in self
sourcefn minmaxt(self) -> (T, T)where
T: PartialOrd + Clone,
fn minmaxt(self) -> (T, T)where
T: PartialOrd + Clone,
Minimum and maximum values in self
sourcefn minmax(self) -> MinMax<T>where
T: PartialOrd + Clone,
fn minmax(self) -> MinMax<T>where
T: PartialOrd + Clone,
Returns MinMax{min, minindex, max, maxindex}
sourcefn minmax_slice(self, i: usize, n: usize) -> MinMax<T>where
T: PartialOrd + Clone,
fn minmax_slice(self, i: usize, n: usize) -> MinMax<T>where
T: PartialOrd + Clone,
MinMax of n items starting at subscript i
sourcefn minmax_indexed(self, idx: &[usize], i: usize, n: usize) -> MinMax<T>where
T: PartialOrd + Clone,
fn minmax_indexed(self, idx: &[usize], i: usize, n: usize) -> MinMax<T>where
T: PartialOrd + Clone,
MinMax of a subset of self, defined by its idx subslice between i,i+n.
sourcefn sansrepeat(self) -> Vec<T>
fn sansrepeat(self) -> Vec<T>
Repeated items removed
sourcefn member(self, m: T, forward: bool) -> Option<usize>
fn member(self, m: T, forward: bool) -> Option<usize>
Some(subscript) of the first occurence of m, or None
sourcefn occurs(self, val: T) -> usizewhere
T: PartialOrd,
fn occurs(self, val: T) -> usizewhere
T: PartialOrd,
Counts partially equal occurrences of val by simple linear search of an unPartialOrdered set
sourcefn unite_unsorted(self, v: &[T]) -> Vec<T>where
T: Clone,
fn unite_unsorted(self, v: &[T]) -> Vec<T>where
T: Clone,
Unites (concatenates) two unsorted slices. For union of sorted slices, use merge
sourcefn unite_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
fn unite_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
Unites two ascending index-sorted slices.
sourcefn intersect(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
fn intersect(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
Intersects two ascending explicitly sorted generic vectors.
sourcefn intersect_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
fn intersect_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
Intersects two ascending index sorted vectors.
sourcefn diff(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
fn diff(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
Removes items of sorted v2 from sorted self.
sourcefn diff_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
fn diff_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
Removes items of v2 from self using their sort indices.
sourcefn partition(self, pivot: &T) -> (Vec<T>, Vec<T>, Vec<T>)where
T: PartialOrd + Clone,
fn partition(self, pivot: &T) -> (Vec<T>, Vec<T>, Vec<T>)where
T: PartialOrd + Clone,
Divides an unordered set into three: items smaller than pivot, equal, and greater
sourcefn partition_indexed(self, pivot: &T) -> (Vec<usize>, Vec<usize>, Vec<usize>)where
T: PartialOrd + Clone,
fn partition_indexed(self, pivot: &T) -> (Vec<usize>, Vec<usize>, Vec<usize>)where
T: PartialOrd + Clone,
Divides an unordered set into three by the pivot. The results are subscripts to self
sourcefn binsearch(self, target: &T) -> Range<usize>where
T: PartialOrd + Copy,
fn binsearch(self, target: &T) -> Range<usize>where
T: PartialOrd + Copy,
Binary Search. Automatic descending PartialOrder detection.
sourcefn binsearch_indexed(self, idx: &[usize], target: &T) -> Range<usize>where
T: PartialOrd + Copy,
fn binsearch_indexed(self, idx: &[usize], target: &T) -> Range<usize>where
T: PartialOrd + Copy,
Binary Search via index. Automatic descending PartialOrder detection
sourcefn merge(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
fn merge(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
Merges (unites) two sorted sets, result is also sorted
sourcefn merge_indexed(
self,
idx1: &[usize],
v2: &[T],
idx2: &[usize]
) -> (Vec<T>, Vec<usize>)where
T: PartialOrd + Clone,
fn merge_indexed(
self,
idx1: &[usize],
v2: &[T],
idx2: &[usize]
) -> (Vec<T>, Vec<usize>)where
T: PartialOrd + Clone,
Merges (unites) two sets, using their sort indices, giving also the resulting sort index
sourcefn merge_indices(self, idx1: &[usize], idx2: &[usize]) -> Vec<usize>where
T: PartialOrd + Clone,
fn merge_indices(self, idx1: &[usize], idx2: &[usize]) -> Vec<usize>where
T: PartialOrd + Clone,
Used by merge_indexed
sourcefn mergesort_indexed(self) -> Vec<usize>where
T: PartialOrd + Clone,
fn mergesort_indexed(self) -> Vec<usize>where
T: PartialOrd + Clone,
Stable Merge sort main method, giving sort index
sourcefn mergesortslice(self, i: usize, n: usize) -> Vec<usize>where
T: PartialOrd + Clone,
fn mergesortslice(self, i: usize, n: usize) -> Vec<usize>where
T: PartialOrd + Clone,
Utility used by mergesort_indexed
sourcefn sortm(self, ascending: bool) -> Vec<T>where
T: PartialOrd + Clone,
fn sortm(self, ascending: bool) -> Vec<T>where
T: PartialOrd + Clone,
Stable Merge sort, explicitly sorted result obtained via mergesort_indexed
sourcefn rank(self, ascending: bool) -> Vec<usize>where
T: PartialOrd + Clone,
fn rank(self, ascending: bool) -> Vec<usize>where
T: PartialOrd + Clone,
Rank index obtained via mergesort_indexed
sourcefn isorttwo(self, idx: &mut [usize], i0: usize, i1: usize)where
T: PartialOrd,
fn isorttwo(self, idx: &mut [usize], i0: usize, i1: usize)where
T: PartialOrd,
Utility, swaps any two items into ascending order
sourcefn isortthree(self, idx: &mut [usize], i0: usize, i1: usize, i2: usize)where
T: PartialOrd,
fn isortthree(self, idx: &mut [usize], i0: usize, i1: usize, i2: usize)where
T: PartialOrd,
Utility, sorts any three items into ascending order
sourcefn hashsort_indexed(self, quantify: impl Copy + Fn(&T) -> f64) -> Vec<usize>where
T: PartialOrd + Clone,
fn hashsort_indexed(self, quantify: impl Copy + Fn(&T) -> f64) -> Vec<usize>where
T: PartialOrd + Clone,
Stable hash sort giving sort index
sourcefn hashsortslice(
self,
idx: &mut [usize],
i: usize,
n: usize,
min: f64,
max: f64,
quantify: impl Copy + Fn(&T) -> f64
)where
T: PartialOrd + Clone,
fn hashsortslice(
self,
idx: &mut [usize],
i: usize,
n: usize,
min: f64,
max: f64,
quantify: impl Copy + Fn(&T) -> f64
)where
T: PartialOrd + Clone,
Utility used by hashsort_indexed
sourcefn sorth(self, quantify: impl Copy + Fn(&T) -> f64, ascending: bool) -> Vec<T>where
T: PartialOrd + Clone,
fn sorth(self, quantify: impl Copy + Fn(&T) -> f64, ascending: bool) -> Vec<T>where
T: PartialOrd + Clone,
Stable hash sort. Returns new sorted data vector (ascending or descending)
sourcefn smallest_k(&self, k: usize) -> BinaryHeap<&T>where
T: Ord,
fn smallest_k(&self, k: usize) -> BinaryHeap<&T>where
T: Ord,
Heap of k smallest items in no particular order, except the first one is maximum. Best for finding just the one k-ranked item
sourcefn biggest_k(&self, k: usize) -> BinaryHeap<Reverse<&T>>where
T: Ord,
fn biggest_k(&self, k: usize) -> BinaryHeap<Reverse<&T>>where
T: Ord,
Heap of k biggest items in no particular order, except the first one is minimum Best for finding just the one k complement ranked item (k-th from the end).
sourcefn isort_indexed<F>(self, rng: Range<usize>, c: F) -> Vec<usize>
fn isort_indexed<F>(self, rng: Range<usize>, c: F) -> Vec<usize>
Sort index by insert logsort. Preserves data.
Insert logsort, returns sort index. Reverse c
for descending order
Provided Methods§
Object Safety§
Implementations on Foreign Types§
source§impl<'a, T> Vecops<'a, T> for &'a [T]
impl<'a, T> Vecops<'a, T> for &'a [T]
source§fn ref_vec(self, rng: Range<usize>) -> Vec<&'a T>
fn ref_vec(self, rng: Range<usize>) -> Vec<&'a T>
Creates a vector of references to input items.
Avoids moving large end types T around.
source§fn tof64(self) -> Vec<f64>
fn tof64(self) -> Vec<f64>
Helper function to copy and cast entire &[T] to Vec<f64>
.
Like the standard .to_vec()
method but also recasts to f64 end type
source§fn maxt(self) -> Twhere
T: PartialOrd + Clone,
fn maxt(self) -> Twhere
T: PartialOrd + Clone,
Maximum value T of slice &[T]
source§fn mint(self) -> Twhere
T: PartialOrd + Clone,
fn mint(self) -> Twhere
T: PartialOrd + Clone,
Minimum value T of slice &[T]
source§fn minmaxt(self) -> (T, T)where
T: PartialOrd + Clone,
fn minmaxt(self) -> (T, T)where
T: PartialOrd + Clone,
Minimum and maximum (T,T) of a slice &[T]
source§fn minmax(self) -> MinMax<T>where
T: PartialOrd + Clone,
fn minmax(self) -> MinMax<T>where
T: PartialOrd + Clone,
Minimum, minimum’s first index, maximum, maximum’s first index
source§fn minmax_slice(self, i: usize, n: usize) -> MinMax<T>where
T: PartialOrd + Clone,
fn minmax_slice(self, i: usize, n: usize) -> MinMax<T>where
T: PartialOrd + Clone,
Finds min and max of a subset of self, defined by its subslice between i,i+n. Returns min of self, its index, max of self, its index.
source§fn minmax_indexed(self, idx: &[usize], i: usize, n: usize) -> MinMax<T>where
T: PartialOrd + Clone,
fn minmax_indexed(self, idx: &[usize], i: usize, n: usize) -> MinMax<T>where
T: PartialOrd + Clone,
Using only a subset of self, defined by its idx subslice between i,i+n. Returns min of self, its index’s index, max of self, its index’s index.
source§fn revs(self) -> Vec<T>where
T: Clone,
fn revs(self) -> Vec<T>where
T: Clone,
Reverse a generic slice by reverse iteration. Creates a new Vec. Its naive use for descending sort etc. is to be avoided for efficiency reasons.
source§fn sansrepeat(self) -> Vec<T>
fn sansrepeat(self) -> Vec<T>
Removes repetitions from an explicitly PartialOrdered set.
source§fn member(self, m: T, forward: bool) -> Option<usize>
fn member(self, m: T, forward: bool) -> Option<usize>
Finds the first/last occurence of item m
in self by forward/backward iteration.
Returns Some(index)
of the found item or None
.
Suitable for small unPartialOrdered lists.
For longer lists, it is better to sort them and use binsearch
(see below).
For repeated tests, index sort first and then use `binsearch_indexed.
source§fn occurs(self, val: T) -> usizewhere
T: PartialOrd,
fn occurs(self, val: T) -> usizewhere
T: PartialOrd,
Counts partial equal occurrences of val by simple linear search of any unPartialOrdered set
source§fn unite_unsorted(self, v: &[T]) -> Vec<T>where
T: Clone,
fn unite_unsorted(self, v: &[T]) -> Vec<T>where
T: Clone,
Unites (joins) two unsorted sets. For union of sorted sets, use merge
source§fn unite_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
fn unite_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
Unites two ascending index-sorted generic vectors. This is the union of two index sorted sets. Returns a single explicitly PartialOrdered set.
source§fn intersect(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
fn intersect(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
Intersects two ascending explicitly sorted generic vectors.
source§fn intersect_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
fn intersect_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
Intersects two ascending index-sorted generic vectors. Returns a single explicitly PartialOrdered set.
source§fn diff(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
fn diff(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
Sets difference: deleting elements of the second from the first. Two ascending explicitly sorted generic vectors.
source§fn diff_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
fn diff_indexed(self, ix1: &[usize], v2: &[T], ix2: &[usize]) -> Vec<T>where
T: PartialOrd + Clone,
Sets difference: deleting elements of the second from the first. Two ascending index sorted generic vectors.
source§fn partition(self, pivot: &T) -> (Vec<T>, Vec<T>, Vec<T>)where
T: PartialOrd + Clone,
fn partition(self, pivot: &T) -> (Vec<T>, Vec<T>, Vec<T>)where
T: PartialOrd + Clone,
Partition with respect to a pivot into three sets
source§fn partition_indexed(self, pivot: &T) -> (Vec<usize>, Vec<usize>, Vec<usize>)where
T: PartialOrd + Clone,
fn partition_indexed(self, pivot: &T) -> (Vec<usize>, Vec<usize>, Vec<usize>)where
T: PartialOrd + Clone,
Partition by pivot gives three sets of indices.
source§fn binsearch(self, target: &T) -> Range<usize>where
T: PartialOrd,
fn binsearch(self, target: &T) -> Range<usize>where
T: PartialOrd,
Binary Search with automatic descending PartialOrder detection.
source§fn binsearch_indexed(self, idx: &[usize], target: &T) -> Range<usize>where
T: PartialOrd,
fn binsearch_indexed(self, idx: &[usize], target: &T) -> Range<usize>where
T: PartialOrd,
Binary Search via index with automatic PartialOrder detection.
source§fn merge(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
fn merge(self, v2: &[T]) -> Vec<T>where
T: PartialOrd + Clone,
Merges two explicitly ascending sorted generic vectors, by classical selection and copying of their head items into the result. Consider using merge_indexed instead, especially for non-primitive end types T.
source§fn merge_indexed(
self,
idx1: &[usize],
v2: &[T],
idx2: &[usize]
) -> (Vec<T>, Vec<usize>)where
T: PartialOrd + Clone,
fn merge_indexed(
self,
idx1: &[usize],
v2: &[T],
idx2: &[usize]
) -> (Vec<T>, Vec<usize>)where
T: PartialOrd + Clone,
Merges two ascending sort indices. Data is not shuffled at all, v2 is just concatenated onto v1 in one go and both remain in their original PartialOrder. Returns the concatenated vector and a new valid sort index into it.
source§fn merge_indices(self, idx1: &[usize], idx2: &[usize]) -> Vec<usize>where
T: PartialOrd + Clone,
fn merge_indices(self, idx1: &[usize], idx2: &[usize]) -> Vec<usize>where
T: PartialOrd + Clone,
Merges the sort indices of two concatenated vectors.
Data in self is not changed at all, only consulted for the comparisons.
This function is used by mergesort
and merge_indexed
.
source§fn mergesortslice(self, i: usize, n: usize) -> Vec<usize>where
T: PartialOrd + Clone,
fn mergesortslice(self, i: usize, n: usize) -> Vec<usize>where
T: PartialOrd + Clone,
Doubly recursive non-destructive merge sort. The data is not moved or mutated. Efficiency is comparable to quicksort but more stable Returns a vector of indices to s from i to i+n, such that the indexed values are in ascending sort PartialOrder (a sort index). Only the index values are being moved.
source§fn mergesort_indexed(self) -> Vec<usize>where
T: PartialOrd + Clone,
fn mergesort_indexed(self) -> Vec<usize>where
T: PartialOrd + Clone,
The main mergesort Wraps mergesortslice, to obtain the whole sort index
source§fn sortm(self, ascending: bool) -> Vec<T>where
T: PartialOrd + Clone,
fn sortm(self, ascending: bool) -> Vec<T>where
T: PartialOrd + Clone,
Immutable merge sort. Returns new sorted data vector (ascending or descending). Wraps mergesortslice. Mergesortslice and mergesort_indexed produce only an ascending index. Sortm will produce descending data PartialOrder with ascending == false.
source§fn rank(self, ascending: bool) -> Vec<usize>where
T: PartialOrd + Clone,
fn rank(self, ascending: bool) -> Vec<usize>where
T: PartialOrd + Clone,
Fast ranking of many T items, with only n*(log(n)+1)
complexity.
Ranking is done by inverting the sort index.
Sort index is in sorted PartialOrder, giving data positions.
Ranking is in data PartialOrder, giving sorted PartialOrder positions.
Thus sort index and ranks are in an inverse relationship.
They are easily converted by .invindex()
(for: invert index).
source§fn isorttwo(self, idx: &mut [usize], i0: usize, i1: usize)where
T: PartialOrd,
fn isorttwo(self, idx: &mut [usize], i0: usize, i1: usize)where
T: PartialOrd,
swap any two index items, if their data items (self) are not in ascending PartialOrder
source§fn isortthree(self, idx: &mut [usize], i0: usize, i1: usize, i2: usize)where
T: PartialOrd,
fn isortthree(self, idx: &mut [usize], i0: usize, i1: usize, i2: usize)where
T: PartialOrd,
sort three index items if their self items are out of ascending PartialOrder
source§fn hashsort_indexed(self, quantify: impl Copy + Fn(&T) -> f64) -> Vec<usize>where
T: PartialOrd + Clone,
fn hashsort_indexed(self, quantify: impl Copy + Fn(&T) -> f64) -> Vec<usize>where
T: PartialOrd + Clone,
N recursive non-destructive hash sort. Input data are read only. Output is sort index.
source§fn sorth(self, quantify: impl Copy + Fn(&T) -> f64, ascending: bool) -> Vec<T>where
T: PartialOrd + Clone,
fn sorth(self, quantify: impl Copy + Fn(&T) -> f64, ascending: bool) -> Vec<T>where
T: PartialOrd + Clone,
Immutable hash sort. Returns new sorted data vector (ascending or descending). Wraps mergesortslice. Mergesortslice and mergesort_indexed produce only an ascending index. Sortm will produce descending data PartialOrder with ascending == false.
source§fn smallest_k(&self, k: usize) -> BinaryHeap<&T>where
T: Ord,
fn smallest_k(&self, k: usize) -> BinaryHeap<&T>where
T: Ord,
Heap of k smallest items in no particular PartialOrder, except the first one is maximum
source§fn biggest_k(&self, k: usize) -> BinaryHeap<Reverse<&T>>where
T: Ord,
fn biggest_k(&self, k: usize) -> BinaryHeap<Reverse<&T>>where
T: Ord,
Heap of k biggest items in no particular PartialOrder, except the first one is minimum
source§fn isort_indexed<F>(self, rng: Range<usize>, c: F) -> Vec<usize>
fn isort_indexed<F>(self, rng: Range<usize>, c: F) -> Vec<usize>
Sort index by insert logsort. Preserves data.
Returns sort index of data in subslice defined by rng
.
Pass in reversed comparator c
for descending sort.
source§fn isort_refs<F>(self, rng: Range<usize>, c: F) -> Vec<&'a T>
fn isort_refs<F>(self, rng: Range<usize>, c: F) -> Vec<&'a T>
Insert logsort of refs (in range).
Useful for large types T, as they are not copied.
Pass in reversed comparator c
for descending sort.
source§fn best_k<F>(self, k: usize, rng: Range<usize>, c: F) -> Vec<&'a T>
fn best_k<F>(self, k: usize, rng: Range<usize>, c: F) -> Vec<&'a T>
First k sorted items from rng (ascending or descending, depending on c
)