pub struct ProcessSort {
pub key: ProcessSortKey,
pub direction: SortDirection,
}Expand description
A complete process table ordering: which column, and which way round.
Fields§
§key: ProcessSortKeyThe column being sorted.
direction: SortDirectionThe direction of the value comparison.
Implementations§
Source§impl ProcessSort
impl ProcessSort
Sourcepub const fn new(key: ProcessSortKey, direction: SortDirection) -> Self
pub const fn new(key: ProcessSortKey, direction: SortDirection) -> Self
Builds an ordering.
Sourcepub const fn descending(key: ProcessSortKey) -> Self
pub const fn descending(key: ProcessSortKey) -> Self
Builds a descending ordering, which is what almost every metric column wants: the interesting rows are the big ones.
Sourcepub const fn ascending(key: ProcessSortKey) -> Self
pub const fn ascending(key: ProcessSortKey) -> Self
Builds an ascending ordering.
Sourcepub const fn with_key(self, key: ProcessSortKey) -> Self
pub const fn with_key(self, key: ProcessSortKey) -> Self
A different column, keeping the current direction.
Picking a column from the selector (s, §6.2) must not silently flip the
direction as well; §7.2 forbids the table rearranging in ways the user did
not ask for.
Sourcepub fn compare(
&self,
left: &ProcessSnapshot,
right: &ProcessSnapshot,
) -> Ordering
pub fn compare( &self, left: &ProcessSnapshot, right: &ProcessSnapshot, ) -> Ordering
Compares two processes under this ordering.
A total order: reflexive, antisymmetric, and transitive, with the identity
tie-break guaranteeing that only genuinely identical processes compare
Ordering::Equal. That is what makes it safe to hand to
slice::sort_by and what keeps two refreshes of the same table in the
same order (§7.2).
Sourcepub fn sort<P: Borrow<ProcessSnapshot>>(&self, rows: &mut [P])
pub fn sort<P: Borrow<ProcessSnapshot>>(&self, rows: &mut [P])
Sorts rows in place under this ordering.
Generic over Borrow so it works on an owned Vec<ProcessSnapshot> and on
a borrowed Vec<&ProcessSnapshot> alike.
Trait Implementations§
Source§impl Clone for ProcessSort
impl Clone for ProcessSort
Source§fn clone(&self) -> ProcessSort
fn clone(&self) -> ProcessSort
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more