simplify n_subset_of_n
This commit is contained in:
parent
e6a6dc847e
commit
37263f983a
@ -94,6 +94,22 @@ impl<'a, T: 'a + MonadFail<'a, ()>, A: 'a + Clone, D: 'a + PartialEq> SubsetCont
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn outside_l<A>(comparator: &dyn Comparator<A>, k_l: &Option<A>, k_super: &A) -> bool {
|
||||||
|
if let Some(a_l) = k_l {
|
||||||
|
comparator.compare(a_l, k_super) == Comparison::R
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn outside_r<A>(comparator: &dyn Comparator<A>, k_r: &Option<A>, k_super: &A) -> bool {
|
||||||
|
if let Some(a_r) = k_r {
|
||||||
|
comparator.compare(a_r, k_super) == Comparison::L
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn n_subset_of_n<'a, T: MonadFail<'a, ()>, A: 'a + Clone, D: 'a + PartialEq>(
|
pub fn n_subset_of_n<'a, T: MonadFail<'a, ()>, A: 'a + Clone, D: 'a + PartialEq>(
|
||||||
comparator: &'a dyn Comparator<A>,
|
comparator: &'a dyn Comparator<A>,
|
||||||
n_subset: Rc<dyn TraversibleBinaryNode<'a, T, A, D>>,
|
n_subset: Rc<dyn TraversibleBinaryNode<'a, T, A, D>>,
|
||||||
@ -102,16 +118,11 @@ pub fn n_subset_of_n<'a, T: MonadFail<'a, ()>, A: 'a + Clone, D: 'a + PartialEq>
|
|||||||
k_r: Option<A>,
|
k_r: Option<A>,
|
||||||
) -> T::F<()> {
|
) -> T::F<()> {
|
||||||
let (t_superl, t_superr, k_super) = n_superset.split();
|
let (t_superl, t_superr, k_super) = n_superset.split();
|
||||||
if let Some(ref a_l) = k_l {
|
if outside_l(comparator, &k_l, &k_super) {
|
||||||
if let Comparison::R = comparator.compare(a_l, &k_super) {
|
t_subset_of_t(comparator, n_subset.to_tree(), t_superr, k_l, k_r)
|
||||||
return t_subset_of_t(comparator, n_subset.to_tree(), t_superr, k_l, k_r);
|
} else if outside_r(comparator, &k_r, &k_super) {
|
||||||
}
|
t_subset_of_t(comparator, n_subset.to_tree(), t_superl, k_l, k_r)
|
||||||
}
|
} else {
|
||||||
if let Some(ref a_r) = k_r {
|
|
||||||
if let Comparison::L = comparator.compare(a_r, &k_super) {
|
|
||||||
return t_subset_of_t(comparator, n_subset.to_tree(), t_superl, k_l, k_r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SubsetContext {
|
SubsetContext {
|
||||||
comparator,
|
comparator,
|
||||||
n_subset,
|
n_subset,
|
||||||
@ -124,6 +135,7 @@ pub fn n_subset_of_n<'a, T: MonadFail<'a, ()>, A: 'a + Clone, D: 'a + PartialEq>
|
|||||||
}
|
}
|
||||||
.test()
|
.test()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn r_subset_of_r<'a, T: MonadFail<'a, ()>, A: 'a + Clone, D: 'a + PartialEq>(
|
pub fn r_subset_of_r<'a, T: MonadFail<'a, ()>, A: 'a + Clone, D: 'a + PartialEq>(
|
||||||
comparator: &'a dyn Comparator<A>,
|
comparator: &'a dyn Comparator<A>,
|
||||||
|
Loading…
Reference in New Issue
Block a user