use std::cmp::Ordering;
use super::SweepPoint;
use crate::GeoNum;
#[derive(Debug)]
pub(crate) struct Event<T: GeoNum, P> {
pub point: SweepPoint<T>,
pub ty: EventType,
pub payload: P,
}
impl<T: GeoNum, P> PartialEq for Event<T, P> {
fn eq(&self, other: &Self) -> bool {
self.point == other.point && self.ty == other.ty
}
}
impl<T: GeoNum, P> Eq for Event<T, P> {}
impl<T: GeoNum, P> PartialOrd for Event<T, P> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<T: GeoNum, P> Ord for Event<T, P> {
fn cmp(&self, other: &Self) -> Ordering {
self.point
.cmp(&other.point)
.then_with(|| self.ty.cmp(&other.ty))
.reverse()
}
}
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Copy)]
pub(crate) enum EventType {
PointLeft,
LineRight,
LineLeft,
PointRight,
}