remove avl::context

This commit is contained in:
AF 2023-06-18 14:42:44 +00:00
parent fce211571f
commit 7ac9ee1bec
2 changed files with 0 additions and 72 deletions
src/rstd/collections

View File

@ -1,5 +1,4 @@
pub mod binary;
pub mod context;
use std::{error::Error, fmt::Display, rc::Rc};

View File

@ -1,71 +0,0 @@
use std::marker::PhantomData;
use crate::{
flow::{binary::*, comparator::*},
func::context::*,
rstd::fallible::*,
};
use super::{binary::*, *};
struct AvlTrees<C, T>(Rc<C>, PhantomData<T>);
impl<C, T> AvlTrees<C, T> {
fn new(comparator: Rc<C>) -> Self {
Self(comparator, PhantomData)
}
}
impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx> + Clone, C: 'a + Comparator<A>> Clone
for AvlTrees<C, (Ctx, A)>
{
fn clone(&self) -> Self {
Self::new(self.0.clone())
}
}
impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx> + Clone, C: 'a + Comparator<A>>
FunctorContext<'a> for AvlTrees<C, (Ctx, A)>
{
type T = FallibleMonad<
'a,
Ctx,
ResolutionError<Ctx::LookupError, AvlError<ParseError<'a, Ctx, Fctr<'a, Ctx, A>>>>,
>;
}
impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx> + Clone, C: 'a + Comparator<A>> BinaryTrees<'a>
for AvlTrees<C, (Ctx, A)>
{
type Node = AvlNode<'a, Ctx, A>;
type Reference = AvlReference<'a, Ctx, A>;
type Tree = AvlTree<'a, Ctx, A>;
type Key = A;
type Comparator = C;
type _Tm = Self::T;
fn comparator(&self) -> &Self::Comparator {
&self.0
}
fn split(&self, node: &Self::Node) -> Split<'a, Self> {
(node.l.clone(), node.r.clone(), node.key.clone())
}
fn resolve(&self, reference: &Self::Reference) -> BTWrap<'a, Self, Self::Node> {
Self::fmap(Ctx::stuff(reference.resolve()), |rc| rc.as_ref().clone())
}
fn equal(&self, rl: &Self::Reference, rr: &Self::Reference) -> bool {
rl == rr
}
fn refer(&self, tree: &Self::Tree) -> Option<Self::Reference> {
tree.reference()
}
}