Trait JudgeOrder

Source
pub trait JudgeOrder<T>: JudgePartialOrder<T> {
    // Provided methods
    fn judge_cmp(&self, lhs: &T, rhs: &T) -> Ordering { ... }
    fn judge_max(&self, lhs: T, rhs: T) -> T { ... }
    fn judge_min(&self, lhs: T, rhs: T) -> T { ... }
    fn judge_clamp(&self, clampee: T, min: T, max: T) -> T { ... }
}
Expand description

Modeled off the Rust trait std::cmp::Ord.

It is commonly the case that multiple different partial orders are relevant to struct. For example, one might want to order simplices in ascending/descending lexicographic order, or first by dimension and second by lexicographic order, etc. The Rust traits for Ord and PartialOrd only accomodate a single order per struct. Therefore we create third-party objects or “operators” to operationalize different orders.

Provided Methods§

Source

fn judge_cmp(&self, lhs: &T, rhs: &T) -> Ordering

Similar to the .cmp method in std::cmp::Ord

Source

fn judge_max(&self, lhs: T, rhs: T) -> T

Return the greater of lhs, rhs; if they are equal, reutrh lhs

Source

fn judge_min(&self, lhs: T, rhs: T) -> T

Return the lesser of lhs, rhx; if they are equal, return lhs

Source

fn judge_clamp(&self, clampee: T, min: T, max: T) -> T

Similar to Rust’s num::clamp

Implementors§

Source§

impl<FilVal: Ord + Clone + Debug> JudgeOrder<SimplexFiltered<FilVal>> for OrderOperatorTwistSimplexFiltered

Source§

impl<Key, Val, KeyValPair> JudgeOrder<KeyValPair> for OrderOperatorByKey<Key, Val, KeyValPair>
where Key: Ord + PartialOrd, KeyValPair: KeyValGet<Key, Val>,

Source§

impl<Key, Val, KeyValPair, KeyComparator> JudgeOrder<KeyValPair> for OrderOperatorByKeyCutsom<Key, Val, KeyValPair, KeyComparator>
where KeyValPair: KeyValGet<Key, Val>, KeyComparator: JudgePartialOrder<Key>,

Source§

impl<T, F: Fn(&T, &T) -> bool> JudgeOrder<T> for OrderOperatorByLessThan<F, T>

Source§

impl<T, UnreversedOrderOperator: JudgePartialOrder<T> + JudgeOrder<T>> JudgeOrder<T> for ReverseOrder<UnreversedOrderOperator>

Source§

impl<T: PartialOrd + Ord> JudgeOrder<T> for OrderOperatorAuto

Source§

impl<T: PartialOrd + Ord> JudgeOrder<T> for OrderOperatorAutoReverse

Source§

impl<Vertex: Ord> JudgeOrder<Vec<Vertex>> for OrderOperatorTwistSimplex