1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
mod heap;
mod inner;
mod outer;

use crate::algorithm::markers::Sorted;
use crate::property::Region;

use inner::{Context, State};

pub use inner::SortedIntersectIter;

pub trait SortedIntersect: Iterator + Sorted + Sized {
    fn sorted_intersect<U: Region + Clone, Other: Iterator<Item = U> + Sorted>(
        self,
        other: Other,
    ) -> SortedIntersectIter<Self, Other>
    where
        Self::Item: Region + Clone,
    {
        SortedIntersectIter {
            context_a: Context::from_iter(self),
            context_b: Context::from_iter(other),
            state: State::FrontierA(0, 0, None),
        }
    }

    fn sorted_left_outer_intersect<U: Region + Clone, Other: Iterator<Item = U> + Sorted>(
        self,
        other: Other,
    ) -> outer::LeftOuterJoinIter<Self, Other>
    where
        Self::Item: Region + Clone,
    {
        outer::LeftOuterJoinIter::new(self, other)
    }
}

impl<I: Iterator + Sorted> SortedIntersect for I {}