#[derive(Hash, Default, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
pub struct Pair<S, T> {
pub first: S,
pub second: T,
}
impl<S, T> Pair<S, T> {
pub fn new(first: S, second: T) -> Self {
Pair { first, second }
}
}
use timely::order::PartialOrder;
impl<S: PartialOrder, T: PartialOrder> PartialOrder for Pair<S, T> {
fn less_equal(&self, other: &Self) -> bool {
self.first.less_equal(&other.first) && self.second.less_equal(&other.second)
}
}
use timely::progress::timestamp::Refines;
impl<S: Timestamp, T: Timestamp> Refines<()> for Pair<S, T> {
fn to_inner(_outer: ()) -> Self {
Default::default()
}
fn to_outer(self) {}
fn summarize(_summary: <Self>::Summary) {}
}
use timely::progress::PathSummary;
impl<S: Timestamp, T: Timestamp> PathSummary<Pair<S, T>> for () {
fn results_in(&self, timestamp: &Pair<S, T>) -> Option<Pair<S, T>> {
Some(timestamp.clone())
}
fn followed_by(&self, other: &Self) -> Option<Self> {
Some(other.clone())
}
}
use timely::progress::Timestamp;
impl<S: Timestamp, T: Timestamp> Timestamp for Pair<S, T> {
type Summary = ();
}
use differential_dataflow::lattice::Lattice;
impl<S: Lattice, T: Lattice> Lattice for Pair<S, T> {
fn minimum() -> Self {
Pair {
first: S::minimum(),
second: T::minimum(),
}
}
fn join(&self, other: &Self) -> Self {
Pair {
first: self.first.join(&other.first),
second: self.second.join(&other.second),
}
}
fn meet(&self, other: &Self) -> Self {
Pair {
first: self.first.meet(&other.first),
second: self.second.meet(&other.second),
}
}
}
use std::fmt::{Debug, Error, Formatter};
impl<TOuter: Debug, TInner: Debug> Debug for Pair<TOuter, TInner> {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
f.write_str(&format!("({:?}, {:?})", self.first, self.second))
}
}
impl<TOuter, TInner> std::ops::Sub for Pair<TOuter, TInner>
where
TOuter: std::ops::Sub<Output = TOuter>,
TInner: std::ops::Sub<Output = TInner>,
{
type Output = Self;
fn sub(self, other: Self) -> Self {
Pair {
first: self.first.sub(other.first),
second: self.second.sub(other.second),
}
}
}