use std::fmt::{Debug, Display};
use crate::Ranges;
pub trait VersionSet: Debug + Display + Clone + Eq {
type V: Debug + Display + Clone + Ord;
fn empty() -> Self;
fn singleton(v: Self::V) -> Self;
fn complement(&self) -> Self;
fn intersection(&self, other: &Self) -> Self;
fn contains(&self, v: &Self::V) -> bool;
fn full() -> Self {
Self::empty().complement()
}
fn union(&self, other: &Self) -> Self {
self.complement()
.intersection(&other.complement())
.complement()
}
fn is_disjoint(&self, other: &Self) -> bool {
self.intersection(other) == Self::empty()
}
fn subset_of(&self, other: &Self) -> bool {
self == &self.intersection(other)
}
}
impl<T: Debug + Display + Clone + Eq + Ord> VersionSet for Ranges<T> {
type V = T;
fn empty() -> Self {
Ranges::empty()
}
fn singleton(v: Self::V) -> Self {
Ranges::singleton(v)
}
fn complement(&self) -> Self {
Ranges::complement(self)
}
fn intersection(&self, other: &Self) -> Self {
Ranges::intersection(self, other)
}
fn contains(&self, v: &Self::V) -> bool {
Ranges::contains(self, v)
}
fn full() -> Self {
Ranges::full()
}
fn union(&self, other: &Self) -> Self {
Ranges::union(self, other)
}
fn is_disjoint(&self, other: &Self) -> bool {
Ranges::is_disjoint(self, other)
}
fn subset_of(&self, other: &Self) -> bool {
Ranges::subset_of(self, other)
}
}