Public mod structure and related minor fixes
This commit is contained in:
parent
6e33460e63
commit
bde59410d5
@ -1,9 +1,7 @@
|
|||||||
use crate::BinaryTreeDirection;
|
use crate::base_context::{BinaryTreeChildrenGetterContext, BinaryTreeDirection};
|
||||||
use crate::context::BinaryTreeChildrenGetterContext;
|
use crate::directed_context::{DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeDirection};
|
||||||
use crate::directed::DirectedBinaryTreeChildrenGetterContext;
|
|
||||||
use crate::direction::DirectedBinaryTreeDirection;
|
|
||||||
|
|
||||||
fn goDown<Ctx: BinaryTreeChildrenGetterContext>(
|
pub fn goDown<Ctx: BinaryTreeChildrenGetterContext>(
|
||||||
ctx: &Ctx,
|
ctx: &Ctx,
|
||||||
root: Ctx::NodeRef,
|
root: Ctx::NodeRef,
|
||||||
dir: BinaryTreeDirection,
|
dir: BinaryTreeDirection,
|
||||||
@ -26,7 +24,7 @@ fn goDown<Ctx: BinaryTreeChildrenGetterContext>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn goDownDirected<Ctx: DirectedBinaryTreeChildrenGetterContext>(
|
pub fn goDownDirected<Ctx: DirectedBinaryTreeChildrenGetterContext>(
|
||||||
ctx: &Ctx,
|
ctx: &Ctx,
|
||||||
root: Ctx::NodeRef,
|
root: Ctx::NodeRef,
|
||||||
dir: DirectedBinaryTreeDirection,
|
dir: DirectedBinaryTreeDirection,
|
||||||
7
src/algo/mod.rs
Normal file
7
src/algo/mod.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
mod go_down;
|
||||||
|
mod set_relation;
|
||||||
|
mod swap;
|
||||||
|
|
||||||
|
pub use go_down::*;
|
||||||
|
pub use set_relation::*;
|
||||||
|
pub use swap::*;
|
||||||
@ -1,7 +1,6 @@
|
|||||||
use crate::context::{BinaryTreeParentSetterContext, NodeRef};
|
use crate::parent2node_clojure::{Parent2NodeSetterClojure, ParentProviderClojure};
|
||||||
use crate::parent2node::clojure::{Parent2NodeSetterClojure, ParentProviderClojure};
|
|
||||||
|
|
||||||
pub unsafe fn setRelation<NodeRef: crate::context::NodeRef>(
|
pub unsafe fn setRelation<NodeRef: crate::NodeRef>(
|
||||||
parent: &mut (
|
parent: &mut (
|
||||||
impl Parent2NodeSetterClojure<NodeRef = NodeRef> + ParentProviderClojure<NodeRef = NodeRef>
|
impl Parent2NodeSetterClojure<NodeRef = NodeRef> + ParentProviderClojure<NodeRef = NodeRef>
|
||||||
),
|
),
|
||||||
@ -11,7 +10,7 @@ pub unsafe fn setRelation<NodeRef: crate::context::NodeRef>(
|
|||||||
parent.setAsParentOf(child);
|
parent.setAsParentOf(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn xSetRelation<NodeRef: crate::context::NodeRef>(
|
pub unsafe fn xSetRelation<NodeRef: crate::NodeRef>(
|
||||||
parent: &mut (
|
parent: &mut (
|
||||||
impl Parent2NodeSetterClojure<NodeRef = NodeRef> + ParentProviderClojure<NodeRef = NodeRef>
|
impl Parent2NodeSetterClojure<NodeRef = NodeRef> + ParentProviderClojure<NodeRef = NodeRef>
|
||||||
),
|
),
|
||||||
@ -1,18 +1,21 @@
|
|||||||
use crate::algos::set_relation::{setRelation, xSetRelation};
|
use crate::algo::set_relation::{setRelation, xSetRelation};
|
||||||
use crate::context::BinaryTreeParentSetterContext;
|
use crate::base_context::BinaryTreeParentSetterContext;
|
||||||
use crate::context::{
|
use crate::base_context::{
|
||||||
BinaryTreeChildrenGetterContext, BinaryTreeChildrenSetterContext, BinaryTreeParentGetterContext,
|
BinaryTreeChildrenGetterContext, BinaryTreeChildrenSetterContext, BinaryTreeParentGetterContext,
|
||||||
};
|
};
|
||||||
use crate::directed::{DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeChildrenSetterContext};
|
use crate::directed_context::{
|
||||||
use crate::parent2node::clojure::{Parent2NodeSetterClojure, ParentProviderClojure};
|
DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeChildrenSetterContext,
|
||||||
use crate::parent2node::fixed_wrapper::{
|
};
|
||||||
FixedLeftParent2NodeGetterClojureFromContext as P2N_L,
|
use crate::parent2node_clojure::{
|
||||||
FixedRightParent2NodeGetterClojureFromContext as P2N_R,
|
|
||||||
FixedForwardParent2NodeGetterClojureFromDirectedContext as P2N_F,
|
FixedForwardParent2NodeGetterClojureFromDirectedContext as P2N_F,
|
||||||
|
FixedLeftParent2NodeGetterClojureFromContext as P2N_L,
|
||||||
FixedOppositeParent2NodeGetterClojureFromDirectedContext as P2N_O,
|
FixedOppositeParent2NodeGetterClojureFromDirectedContext as P2N_O,
|
||||||
|
FixedRightParent2NodeGetterClojureFromContext as P2N_R,
|
||||||
|
Parent2NodeSetterClojure,
|
||||||
|
ParentProviderClojure,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe fn swapDistant<
|
pub unsafe fn swapDistant<
|
||||||
Ctx: BinaryTreeChildrenGetterContext
|
Ctx: BinaryTreeChildrenGetterContext
|
||||||
+ BinaryTreeChildrenSetterContext
|
+ BinaryTreeChildrenSetterContext
|
||||||
+ BinaryTreeParentGetterContext
|
+ BinaryTreeParentGetterContext
|
||||||
@ -47,7 +50,7 @@ unsafe fn swapDistant<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn swapDistantDirected<
|
pub unsafe fn swapDistantDirected<
|
||||||
Ctx: DirectedBinaryTreeChildrenGetterContext
|
Ctx: DirectedBinaryTreeChildrenGetterContext
|
||||||
+ DirectedBinaryTreeChildrenSetterContext
|
+ DirectedBinaryTreeChildrenSetterContext
|
||||||
+ BinaryTreeParentGetterContext
|
+ BinaryTreeParentGetterContext
|
||||||
5
src/algo/swap/mod.rs
Normal file
5
src/algo/swap/mod.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
mod neighbors;
|
||||||
|
mod distant;
|
||||||
|
|
||||||
|
pub use distant::*;
|
||||||
|
pub use neighbors::*;
|
||||||
@ -1,10 +1,10 @@
|
|||||||
use crate::context::BinaryTreeParentGetterContext;
|
use crate::base_context::BinaryTreeParentGetterContext;
|
||||||
use crate::context::BinaryTreeParentSetterContext;
|
use crate::base_context::BinaryTreeParentSetterContext;
|
||||||
use crate::directed::DirectedBinaryTreeChildrenGetterContext;
|
use crate::directed_context::DirectedBinaryTreeChildrenGetterContext;
|
||||||
use crate::directed::DirectedBinaryTreeChildrenSetterContext;
|
use crate::directed_context::DirectedBinaryTreeChildrenSetterContext;
|
||||||
use crate::parent2node::clojure::{Parent2NodeSetterClojure, ParentProviderClojure};
|
use crate::parent2node_clojure::{Parent2NodeSetterClojure, ParentProviderClojure};
|
||||||
|
|
||||||
unsafe fn swapNeighbors<
|
pub unsafe fn swapNeighbors<
|
||||||
Ctx: DirectedBinaryTreeChildrenGetterContext
|
Ctx: DirectedBinaryTreeChildrenGetterContext
|
||||||
+ DirectedBinaryTreeChildrenSetterContext
|
+ DirectedBinaryTreeChildrenSetterContext
|
||||||
+ BinaryTreeParentGetterContext
|
+ BinaryTreeParentGetterContext
|
||||||
@ -1,3 +0,0 @@
|
|||||||
mod go_down;
|
|
||||||
mod swap;
|
|
||||||
mod set_relation;
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
mod neighbors;
|
|
||||||
mod distant;
|
|
||||||
@ -1,7 +1,8 @@
|
|||||||
pub trait NodeRef: Sized + Clone {}
|
use crate::NodeRefContainer;
|
||||||
|
|
||||||
pub trait NodeRefContainer {
|
pub enum BinaryTreeDirection {
|
||||||
type NodeRef: NodeRef;
|
LEFT,
|
||||||
|
RIGHT,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait BinaryTreeRootGetter: NodeRefContainer {
|
pub trait BinaryTreeRootGetter: NodeRefContainer {
|
||||||
@ -1,6 +0,0 @@
|
|||||||
mod context;
|
|
||||||
mod fixed_wrapper;
|
|
||||||
mod dynamic_wrapper;
|
|
||||||
|
|
||||||
pub use context::DirectedBinaryTreeChildrenSetterContext;
|
|
||||||
pub use context::DirectedBinaryTreeChildrenGetterContext;
|
|
||||||
@ -1,5 +1,10 @@
|
|||||||
use crate::NodeRefContainer;
|
use crate::NodeRefContainer;
|
||||||
|
|
||||||
|
pub enum DirectedBinaryTreeDirection {
|
||||||
|
FORWARD,
|
||||||
|
OPPOSITE,
|
||||||
|
}
|
||||||
|
|
||||||
pub trait DirectedBinaryTreeChildrenGetterContext: NodeRefContainer {
|
pub trait DirectedBinaryTreeChildrenGetterContext: NodeRefContainer {
|
||||||
fn getForwardChild(&self, node: Self::NodeRef) -> Option<Self::NodeRef>;
|
fn getForwardChild(&self, node: Self::NodeRef) -> Option<Self::NodeRef>;
|
||||||
fn getOppositeChild(&self, node: Self::NodeRef) -> Option<Self::NodeRef>;
|
fn getOppositeChild(&self, node: Self::NodeRef) -> Option<Self::NodeRef>;
|
||||||
@ -1,9 +1,11 @@
|
|||||||
use crate::NodeRefContainer;
|
use crate::NodeRefContainer;
|
||||||
use crate::context::{BinaryTreeChildrenSetterContext, BinaryTreeChildrenGetterContext, BinaryTreeParentSetterContext, BinaryTreeParentGetterContext};
|
use crate::base_context::{
|
||||||
use crate::directed::context::{
|
BinaryTreeChildrenGetterContext, BinaryTreeChildrenSetterContext, BinaryTreeDirection,
|
||||||
DirectedBinaryTreeChildrenSetterContext, DirectedBinaryTreeChildrenGetterContext,
|
BinaryTreeParentGetterContext, BinaryTreeParentSetterContext,
|
||||||
|
};
|
||||||
|
use crate::directed_context::context::{
|
||||||
|
DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeChildrenSetterContext,
|
||||||
};
|
};
|
||||||
use crate::direction::BinaryTreeDirection;
|
|
||||||
|
|
||||||
pub struct DynamicDirectedBinaryTreeContextFromContext<CtxRef> {
|
pub struct DynamicDirectedBinaryTreeContextFromContext<CtxRef> {
|
||||||
ctx: CtxRef,
|
ctx: CtxRef,
|
||||||
@ -38,17 +40,23 @@ impl<Ctx: NodeRefContainer> NodeRefContainer for DynamicDirectedBinaryTreeContex
|
|||||||
type NodeRef = Ctx::NodeRef;
|
type NodeRef = Ctx::NodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ctx: NodeRefContainer> NodeRefContainer for DynamicDirectedBinaryTreeContextFromContext<&mut Ctx> {
|
impl<Ctx: NodeRefContainer> NodeRefContainer
|
||||||
|
for DynamicDirectedBinaryTreeContextFromContext<&mut Ctx>
|
||||||
|
{
|
||||||
type NodeRef = Ctx::NodeRef;
|
type NodeRef = Ctx::NodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ctx: BinaryTreeParentGetterContext> BinaryTreeParentGetterContext for DynamicDirectedBinaryTreeContextFromContext<&Ctx> {
|
impl<Ctx: BinaryTreeParentGetterContext> BinaryTreeParentGetterContext
|
||||||
|
for DynamicDirectedBinaryTreeContextFromContext<&Ctx>
|
||||||
|
{
|
||||||
fn getParent(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
fn getParent(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
||||||
return self.ctx.getParent(node);
|
return self.ctx.getParent(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ctx: BinaryTreeParentGetterContext> BinaryTreeParentGetterContext for DynamicDirectedBinaryTreeContextFromContext<&mut Ctx> {
|
impl<Ctx: BinaryTreeParentGetterContext> BinaryTreeParentGetterContext
|
||||||
|
for DynamicDirectedBinaryTreeContextFromContext<&mut Ctx>
|
||||||
|
{
|
||||||
fn getParent(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
fn getParent(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
||||||
return self.ctx.getParent(node);
|
return self.ctx.getParent(node);
|
||||||
}
|
}
|
||||||
@ -1,9 +1,9 @@
|
|||||||
use crate::NodeRefContainer;
|
use crate::NodeRefContainer;
|
||||||
use crate::context::{
|
use crate::base_context::{
|
||||||
BinaryTreeChildrenGetterContext, BinaryTreeChildrenSetterContext,
|
BinaryTreeChildrenGetterContext, BinaryTreeChildrenSetterContext,
|
||||||
BinaryTreeParentGetterContext, BinaryTreeParentSetterContext,
|
BinaryTreeParentGetterContext, BinaryTreeParentSetterContext,
|
||||||
};
|
};
|
||||||
use crate::directed::context::{
|
use crate::directed_context::context::{
|
||||||
DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeChildrenSetterContext,
|
DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeChildrenSetterContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
7
src/directed_context/mod.rs
Normal file
7
src/directed_context/mod.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
mod context;
|
||||||
|
mod fixed_wrapper;
|
||||||
|
mod dynamic_wrapper;
|
||||||
|
|
||||||
|
pub use context::*;
|
||||||
|
pub use fixed_wrapper::*;
|
||||||
|
pub use dynamic_wrapper::*;
|
||||||
@ -1,10 +0,0 @@
|
|||||||
#[derive(PartialEq, Eq)]
|
|
||||||
pub enum BinaryTreeDirection {
|
|
||||||
LEFT,
|
|
||||||
RIGHT,
|
|
||||||
}
|
|
||||||
#[derive(PartialEq, Eq)]
|
|
||||||
pub enum DirectedBinaryTreeDirection {
|
|
||||||
FORWARD,
|
|
||||||
OPPOSITE,
|
|
||||||
}
|
|
||||||
13
src/lib.rs
13
src/lib.rs
@ -1,8 +1,7 @@
|
|||||||
mod context;
|
mod misc;
|
||||||
mod directed;
|
|
||||||
mod direction;
|
|
||||||
mod parent2node;
|
|
||||||
mod algos;
|
|
||||||
|
|
||||||
pub use context::NodeRefContainer;
|
pub use misc::*;
|
||||||
pub use direction::BinaryTreeDirection;
|
pub mod algo;
|
||||||
|
pub mod base_context;
|
||||||
|
pub mod directed_context;
|
||||||
|
pub mod parent2node_clojure;
|
||||||
|
|||||||
5
src/misc.rs
Normal file
5
src/misc.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
pub trait NodeRef: Sized + Clone {}
|
||||||
|
|
||||||
|
pub trait NodeRefContainer {
|
||||||
|
type NodeRef: NodeRef;
|
||||||
|
}
|
||||||
@ -1,3 +0,0 @@
|
|||||||
pub mod clojure;
|
|
||||||
pub mod fixed_wrapper;
|
|
||||||
pub mod dynamic_wrappers;
|
|
||||||
@ -1,14 +1,14 @@
|
|||||||
use super::clojure::{Parent2NodeSetterClojure, ParentProviderClojure};
|
use super::{Parent2NodeSetterClojure, ParentProviderClojure};
|
||||||
use crate::BinaryTreeDirection;
|
|
||||||
use crate::NodeRefContainer;
|
use crate::NodeRefContainer;
|
||||||
use crate::context::{BinaryTreeParentSetterContext, BinaryTreeRootGetter};
|
use crate::base_context::{
|
||||||
use crate::context::BinaryTreeRootSetter;
|
BinaryTreeChildrenGetterContext, BinaryTreeChildrenSetterContext, BinaryTreeDirection,
|
||||||
use crate::context::{BinaryTreeChildrenGetterContext, BinaryTreeChildrenSetterContext};
|
BinaryTreeParentSetterContext, BinaryTreeRootGetter, BinaryTreeRootSetter,
|
||||||
use crate::directed::{
|
|
||||||
DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeChildrenSetterContext,
|
|
||||||
};
|
};
|
||||||
use crate::direction::DirectedBinaryTreeDirection;
|
use crate::directed_context::{
|
||||||
use crate::parent2node::clojure::Parent2NodeGetterClojure;
|
DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeChildrenSetterContext,
|
||||||
|
DirectedBinaryTreeDirection,
|
||||||
|
};
|
||||||
|
use crate::parent2node_clojure::clojure::Parent2NodeGetterClojure;
|
||||||
use std::mem::ManuallyDrop;
|
use std::mem::ManuallyDrop;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
@ -24,13 +24,13 @@ union _NodeOrNothing<NodeRef> {
|
|||||||
node: ManuallyDrop<NodeRef>,
|
node: ManuallyDrop<NodeRef>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DynamicParent2NodeGetterClojureFromContext<CtxRef, NodeRef> {
|
pub struct DynamicParent2NodeGetterClojureFromContext<CtxRef, NodeRef> {
|
||||||
dir: Option<BinaryTreeDirection>,
|
dir: Option<BinaryTreeDirection>,
|
||||||
ctx: CtxRef,
|
ctx: CtxRef,
|
||||||
node: _NodeOrNothing<NodeRef>,
|
node: _NodeOrNothing<NodeRef>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DynamicParent2NodeGetterClojureFromDirectedContext<CtxRef, NodeRef> {
|
pub struct DynamicParent2NodeGetterClojureFromDirectedContext<CtxRef, NodeRef> {
|
||||||
dir: Option<DirectedBinaryTreeDirection>,
|
dir: Option<DirectedBinaryTreeDirection>,
|
||||||
ctx: CtxRef,
|
ctx: CtxRef,
|
||||||
node: _NodeOrNothing<NodeRef>,
|
node: _NodeOrNothing<NodeRef>,
|
||||||
@ -38,47 +38,47 @@ struct DynamicParent2NodeGetterClojureFromDirectedContext<CtxRef, NodeRef> {
|
|||||||
|
|
||||||
macro_rules! _constructor {
|
macro_rules! _constructor {
|
||||||
($name:ident $direction:ident) => {
|
($name:ident $direction:ident) => {
|
||||||
impl<'ctx, Ctx: NodeRefContainer> $name <&'ctx Ctx, Ctx::NodeRef> {
|
impl<'ctx, Ctx: NodeRefContainer> $name<&'ctx Ctx, Ctx::NodeRef> {
|
||||||
pub fn wrapNode(
|
pub fn wrapNode(ctx: &'ctx Ctx, node: Ctx::NodeRef, direction: $direction) -> Self {
|
||||||
ctx: &'ctx Ctx, node: Ctx::NodeRef, direction: $direction
|
|
||||||
) -> Self {
|
|
||||||
return Self {
|
return Self {
|
||||||
dir: Some(direction),
|
dir: Some(direction),
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
node: _NodeOrNothing { node: ManuallyDrop::new(node) }
|
node: _NodeOrNothing {
|
||||||
|
node: ManuallyDrop::new(node),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wrapRoot(
|
pub fn wrapRoot(ctx: &'ctx Ctx) -> Self {
|
||||||
ctx: &'ctx Ctx
|
|
||||||
) -> Self {
|
|
||||||
return Self {
|
return Self {
|
||||||
dir: None,
|
dir: None,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
node: _NodeOrNothing { nothing: () }
|
node: _NodeOrNothing { nothing: () },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($name:ident $direction:ident mut) => {
|
($name:ident $direction:ident mut) => {
|
||||||
impl<'ctx, Ctx: NodeRefContainer> $name <&'ctx mut Ctx, Ctx::NodeRef> {
|
impl<'ctx, Ctx: NodeRefContainer> $name<&'ctx mut Ctx, Ctx::NodeRef> {
|
||||||
pub fn wrapNode_mut(
|
pub fn wrapNode_mut(
|
||||||
ctx: &'ctx mut Ctx, node: Ctx::NodeRef, direction: $direction
|
ctx: &'ctx mut Ctx,
|
||||||
|
node: Ctx::NodeRef,
|
||||||
|
direction: $direction,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
return Self {
|
return Self {
|
||||||
dir: Some(direction),
|
dir: Some(direction),
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
node: _NodeOrNothing { node: ManuallyDrop::new(node) }
|
node: _NodeOrNothing {
|
||||||
|
node: ManuallyDrop::new(node),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wrapRoot_mut(
|
pub fn wrapRoot_mut(ctx: &'ctx mut Ctx) -> Self {
|
||||||
ctx: &'ctx mut Ctx
|
|
||||||
) -> Self {
|
|
||||||
return Self {
|
return Self {
|
||||||
dir: None,
|
dir: None,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
node: _NodeOrNothing { nothing: () }
|
node: _NodeOrNothing { nothing: () },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +86,9 @@ macro_rules! _constructor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_constructor!(DynamicParent2NodeGetterClojureFromContext BinaryTreeDirection));
|
_mut_switch!(_constructor!(DynamicParent2NodeGetterClojureFromContext BinaryTreeDirection));
|
||||||
_mut_switch!(_constructor!(DynamicParent2NodeGetterClojureFromDirectedContext DirectedBinaryTreeDirection));
|
_mut_switch!(
|
||||||
|
_constructor!(DynamicParent2NodeGetterClojureFromDirectedContext DirectedBinaryTreeDirection)
|
||||||
|
);
|
||||||
|
|
||||||
macro_rules! _node_ref {
|
macro_rules! _node_ref {
|
||||||
($name:ident $($mut:tt)?) => {
|
($name:ident $($mut:tt)?) => {
|
||||||
@ -97,7 +99,9 @@ macro_rules! _node_ref {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_node_ref!(DynamicParent2NodeGetterClojureFromContext));
|
_mut_switch!(_node_ref!(DynamicParent2NodeGetterClojureFromContext));
|
||||||
_mut_switch!(_node_ref!(DynamicParent2NodeGetterClojureFromDirectedContext));
|
_mut_switch!(_node_ref!(
|
||||||
|
DynamicParent2NodeGetterClojureFromDirectedContext
|
||||||
|
));
|
||||||
|
|
||||||
macro_rules! _get_child {
|
macro_rules! _get_child {
|
||||||
(
|
(
|
||||||
@ -141,21 +145,20 @@ macro_rules! _set_child {
|
|||||||
$d1_lbl:ident $d1_xset:ident $d1_set:ident $d1_clear:ident
|
$d1_lbl:ident $d1_xset:ident $d1_set:ident $d1_clear:ident
|
||||||
$d2_lbl:ident $d2_xset:ident $d2_set:ident $d2_clear:ident
|
$d2_lbl:ident $d2_xset:ident $d2_set:ident $d2_clear:ident
|
||||||
) => {
|
) => {
|
||||||
impl<
|
impl<'ctx, Ctx: NodeRefContainer + BinaryTreeRootSetter + $ctx_constraint>
|
||||||
'ctx,
|
Parent2NodeSetterClojure for $name<&'ctx mut Ctx, Ctx::NodeRef>
|
||||||
Ctx: NodeRefContainer + BinaryTreeRootSetter + $ctx_constraint
|
|
||||||
> Parent2NodeSetterClojure
|
|
||||||
for $name <&'ctx mut Ctx, Ctx::NodeRef>
|
|
||||||
{
|
{
|
||||||
fn xSetChild(&mut self, newChild: Option<Self::NodeRef>) {
|
fn xSetChild(&mut self, newChild: Option<Self::NodeRef>) {
|
||||||
match self.dir {
|
match self.dir {
|
||||||
None => self.ctx.xSetRoot(newChild),
|
None => self.ctx.xSetRoot(newChild),
|
||||||
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
||||||
self.ctx.$d1_xset ((*self.node.node.deref()).clone(), newChild)
|
self.ctx
|
||||||
|
.$d1_xset((*self.node.node.deref()).clone(), newChild)
|
||||||
},
|
},
|
||||||
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
||||||
self.ctx.$d2_xset ((*self.node.node.deref()).clone(), newChild)
|
self.ctx
|
||||||
}
|
.$d2_xset((*self.node.node.deref()).clone(), newChild)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,11 +166,13 @@ macro_rules! _set_child {
|
|||||||
match self.dir {
|
match self.dir {
|
||||||
None => self.ctx.setRoot(newChild),
|
None => self.ctx.setRoot(newChild),
|
||||||
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
||||||
self.ctx.$d1_set ((*self.node.node.deref()).clone(), newChild)
|
self.ctx
|
||||||
|
.$d1_set((*self.node.node.deref()).clone(), newChild)
|
||||||
},
|
},
|
||||||
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
||||||
self.ctx.$d2_set ((*self.node.node.deref()).clone(), newChild)
|
self.ctx
|
||||||
}
|
.$d2_set((*self.node.node.deref()).clone(), newChild)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,11 +180,11 @@ macro_rules! _set_child {
|
|||||||
match self.dir {
|
match self.dir {
|
||||||
None => self.ctx.clearRoot(),
|
None => self.ctx.clearRoot(),
|
||||||
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
||||||
self.ctx.$d1_clear ((*self.node.node.deref()).clone())
|
self.ctx.$d1_clear((*self.node.node.deref()).clone())
|
||||||
|
},
|
||||||
|
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
||||||
|
self.ctx.$d2_clear((*self.node.node.deref()).clone())
|
||||||
},
|
},
|
||||||
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
|
||||||
self.ctx.$d2_clear ((*self.node.node.deref()).clone())
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,7 +204,6 @@ _set_child!(
|
|||||||
OPPOSITE xSetOppositeChild setOppositeChild clearOppositeChild
|
OPPOSITE xSetOppositeChild setOppositeChild clearOppositeChild
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
macro_rules! _set_as_parent_of {
|
macro_rules! _set_as_parent_of {
|
||||||
($name:ident $dir_enum_lbl:ident $d1_lbl:ident $d2_lbl:ident) => {
|
($name:ident $dir_enum_lbl:ident $d1_lbl:ident $d2_lbl:ident) => {
|
||||||
impl<'ctx, Ctx: BinaryTreeParentSetterContext> ParentProviderClojure
|
impl<'ctx, Ctx: BinaryTreeParentSetterContext> ParentProviderClojure
|
||||||
@ -209,11 +213,11 @@ macro_rules! _set_as_parent_of {
|
|||||||
match self.dir {
|
match self.dir {
|
||||||
None => self.ctx.clearParent(child),
|
None => self.ctx.clearParent(child),
|
||||||
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
||||||
self.ctx.setParent(child, (*self.node.node.deref()).clone())
|
self.ctx.setParent(child, (*self.node.node.deref()).clone())
|
||||||
},
|
},
|
||||||
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
||||||
self.ctx.setParent(child, (*self.node.node.deref()).clone())
|
self.ctx.setParent(child, (*self.node.node.deref()).clone())
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,4 +247,3 @@ macro_rules! _drop {
|
|||||||
|
|
||||||
_drop!(DynamicParent2NodeGetterClojureFromContext);
|
_drop!(DynamicParent2NodeGetterClojureFromContext);
|
||||||
_drop!(DynamicParent2NodeGetterClojureFromDirectedContext);
|
_drop!(DynamicParent2NodeGetterClojureFromDirectedContext);
|
||||||
|
|
||||||
@ -1,12 +1,12 @@
|
|||||||
use crate::NodeRefContainer;
|
use crate::NodeRefContainer;
|
||||||
use crate::context::{
|
use crate::base_context::{
|
||||||
BinaryTreeChildrenGetterContext, BinaryTreeChildrenSetterContext,
|
BinaryTreeChildrenGetterContext, BinaryTreeChildrenSetterContext,
|
||||||
BinaryTreeParentSetterContext, BinaryTreeRootGetter, BinaryTreeRootSetter,
|
BinaryTreeParentSetterContext, BinaryTreeRootGetter, BinaryTreeRootSetter,
|
||||||
};
|
};
|
||||||
use crate::directed::{
|
use crate::directed_context::{
|
||||||
DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeChildrenSetterContext,
|
DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeChildrenSetterContext,
|
||||||
};
|
};
|
||||||
use crate::parent2node::clojure::{
|
use crate::parent2node_clojure::clojure::{
|
||||||
Parent2NodeGetterClojure, Parent2NodeSetterClojure, ParentProviderClojure,
|
Parent2NodeGetterClojure, Parent2NodeSetterClojure, ParentProviderClojure,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -55,13 +55,13 @@ macro_rules! _constructor {
|
|||||||
impl<'ctx, Ctx: NodeRefContainer + BinaryTreeRootGetter>
|
impl<'ctx, Ctx: NodeRefContainer + BinaryTreeRootGetter>
|
||||||
FixedRootParent2NodeGetterClojureFromContext<&'ctx Ctx>
|
FixedRootParent2NodeGetterClojureFromContext<&'ctx Ctx>
|
||||||
{
|
{
|
||||||
fn wrap(ctx: &'ctx Ctx) -> Self {
|
pub fn wrap(ctx: &'ctx Ctx) -> Self {
|
||||||
return Self { ctx };
|
return Self { ctx };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, Ctx: NodeRefContainer> FixedRootParent2NodeGetterClojureFromContext<&'ctx mut Ctx> {
|
impl<'ctx, Ctx: NodeRefContainer> FixedRootParent2NodeGetterClojureFromContext<&'ctx mut Ctx> {
|
||||||
fn wrap_mut(ctx: &'ctx mut Ctx) -> Self {
|
pub fn wrap_mut(ctx: &'ctx mut Ctx) -> Self {
|
||||||
return Self { ctx };
|
return Self { ctx };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
7
src/parent2node_clojure/mod.rs
Normal file
7
src/parent2node_clojure/mod.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
mod clojure;
|
||||||
|
mod dynamic_wrappers;
|
||||||
|
mod fixed_wrapper;
|
||||||
|
|
||||||
|
pub use clojure::*;
|
||||||
|
pub use dynamic_wrappers::*;
|
||||||
|
pub use fixed_wrapper::*;
|
||||||
Loading…
Reference in New Issue
Block a user