use crate::InputType;
use crate::beach_line as vb;
use crate::geometry::Point;
use crate::predicate as vp;
use std::cmp::Ordering;
#[derive(Debug)]
pub(crate) struct EndPointPair<I: InputType> {
site_: Point<I>,
beachline_index_: vb::BeachLineIndex,
}
impl<I: InputType> EndPointPair<I> {
pub(crate) fn new(first: Point<I>, second: vb::BeachLineIndex) -> Self {
Self {
site_: first,
beachline_index_: second,
}
}
#[inline(always)]
pub(crate) fn site(&self) -> Point<I> {
self.site_
}
#[inline(always)]
pub(crate) fn beachline_index(&self) -> &vb::BeachLineIndex {
&self.beachline_index_
}
}
impl<I: InputType> PartialOrd for EndPointPair<I> {
#[inline(always)]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<I: InputType> Ord for EndPointPair<I> {
#[inline(always)]
fn cmp(&self, other: &Self) -> Ordering {
if vp::point_comparison::point_comparison(self.site_, other.site_) {
Ordering::Greater
} else if self.site_ == other.site_ {
Ordering::Equal
} else {
Ordering::Less
}
}
}
impl<I: InputType> PartialEq for EndPointPair<I> {
#[inline(always)]
fn eq(&self, other: &Self) -> bool {
self.site_.eq(&other.site_)
}
}
impl<I> Eq for EndPointPair<I> where I: InputType {}