Skip to main content

FiniteLinearOrder

Struct FiniteLinearOrder 

Source
pub struct FiniteLinearOrder {
    pub size: usize,
    pub order: Vec<usize>,
}
Expand description

A finite linear order (totally ordered finite set).

Elements are represented as indices 0..n, with a permutation defining the order.

Fields§

§size: usize

Number of elements.

§order: Vec<usize>

The permutation defining the order: order[i] is the i-th smallest element.

Implementations§

Source§

impl FiniteLinearOrder

Source

pub fn identity(n: usize) -> Self

Create the identity linear order on {0, …, n-1}.

Source

pub fn from_permutation(perm: Vec<usize>) -> Option<Self>

Create a linear order from a permutation.

Source

pub fn compare(&self, a: usize, b: usize) -> Ordering

Compare two elements a, b (by their rank in the order).

Source

pub fn rank(&self, a: usize) -> Option<usize>

Get the rank (0-indexed position) of an element.

Source

pub fn min_elem(&self) -> Option<usize>

Get the minimum element.

Source

pub fn max_elem(&self) -> Option<usize>

Get the maximum element.

Source

pub fn is_well_founded(&self) -> bool

Check if the order is well-founded (always true for finite sets).

Source

pub fn reverse_order(&self) -> FiniteLinearOrder

Reverse the order.

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