use crate::integer_polynomial::{ShortlexIntegerPolynomial, ShortlexIntegerPolynomialRef};
use core::cmp::Ordering;
impl Ord for ShortlexIntegerPolynomialRef<'_> {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
self.0
.coefficients
.len()
.cmp(&other.0.coefficients.len())
.then_with(|| {
self.0
.coefficients
.iter()
.rev()
.cmp(other.0.coefficients.iter().rev())
})
}
}
impl PartialOrd for ShortlexIntegerPolynomialRef<'_> {
#[inline]
fn partial_cmp(&self, other: &ShortlexIntegerPolynomialRef) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for ShortlexIntegerPolynomial {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
self.as_ref().cmp(&other.as_ref())
}
}
impl PartialOrd for ShortlexIntegerPolynomial {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}