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§
Sourcefn judge_max(&self, lhs: T, rhs: T) -> T
fn judge_max(&self, lhs: T, rhs: T) -> T
Return the greater of lhs, rhs; if they are equal, reutrh lhs
Sourcefn judge_min(&self, lhs: T, rhs: T) -> T
fn judge_min(&self, lhs: T, rhs: T) -> T
Return the lesser of lhs, rhx; if they are equal, return lhs
Sourcefn judge_clamp(&self, clampee: T, min: T, max: T) -> T
fn judge_clamp(&self, clampee: T, min: T, max: T) -> T
Similar to Rust’s num::clamp