Skip to main content

ProcessSort

Struct ProcessSort 

Source
pub struct ProcessSort {
    pub key: ProcessSortKey,
    pub direction: SortDirection,
}
Expand description

A complete process table ordering: which column, and which way round.

Fields§

§key: ProcessSortKey

The column being sorted.

§direction: SortDirection

The direction of the value comparison.

Implementations§

Source§

impl ProcessSort

Source

pub const fn new(key: ProcessSortKey, direction: SortDirection) -> Self

Builds an ordering.

Source

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.

Source

pub const fn ascending(key: ProcessSortKey) -> Self

Builds an ascending ordering.

Source

pub const fn reversed(self) -> Self

The same column, sorted the other way round (S, §6.2).

Source

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.

Source

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).

Source

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.

Source

pub fn order<P: Borrow<ProcessSnapshot>>(&self, rows: &[P]) -> Vec<usize>

The display order of rows, as indices into rows.

Returning indices keeps the published snapshot immutable (§10.4) and avoids cloning a process table that can hold ten thousand rows (§16.1).

Trait Implementations§

Source§

impl Clone for ProcessSort

Source§

fn clone(&self) -> ProcessSort

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ProcessSort

Source§

impl Debug for ProcessSort

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ProcessSort

Source§

fn default() -> ProcessSort

Returns the “default value” for a type. Read more
Source§

impl Eq for ProcessSort

Source§

impl Hash for ProcessSort

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ProcessSort

Source§

fn eq(&self, other: &ProcessSort) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ProcessSort

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.