pub struct ComposedStack<'a, S1, S2, F, VO>where
S1: Stack,
S2: Stack<Point = S1::CapPt>,
F: Fn(&S1::VerticalPayload, &S2::VerticalPayload) -> VO,
VO: Clone,{
pub lower: &'a S1,
pub upper: &'a S2,
pub compose_payload: F,
/* private fields */
}Expand description
A stack composed of two existing stacks: lower: base -> mid and upper: mid -> cap.
Traversal composes payloads via a compose_payload function.
§Examples
Using [Polarity] payloads (XOR composition):
use mesh_sieve::topology::arrow::Polarity;
use mesh_sieve::topology::stack::{ComposedStack, InMemoryStack, Stack};
use mesh_sieve::topology::point::PointId;
let s1 = InMemoryStack::<PointId, PointId, Polarity>::new();
let s2 = InMemoryStack::<PointId, PointId, Polarity>::new();
let _cs = ComposedStack::new(&s1, &s2, |a, b| (*a) ^ (*b));Using group-valued [orientation::Sign] with trait composition:
use mesh_sieve::topology::orientation::Sign;
use mesh_sieve::topology::sieve::oriented::Orientation as _;
use mesh_sieve::topology::stack::{ComposedStack, InMemoryStack, Stack};
use mesh_sieve::topology::point::PointId;
let s1 = InMemoryStack::<PointId, PointId, Sign>::new();
let s2 = InMemoryStack::<PointId, PointId, Sign>::new();
let _cs = ComposedStack::new(&s1, &s2, |a, b| Sign::compose(*a, *b));Fields§
§lower: &'a S1§upper: &'a S2§compose_payload: FImplementations§
Source§impl<'a, S1, S2, F, VO> ComposedStack<'a, S1, S2, F, VO>where
S1: Stack,
S2: Stack<Point = S1::CapPt>,
F: Fn(&S1::VerticalPayload, &S2::VerticalPayload) -> VO,
VO: Clone,
impl<'a, S1, S2, F, VO> ComposedStack<'a, S1, S2, F, VO>where
S1: Stack,
S2: Stack<Point = S1::CapPt>,
F: Fn(&S1::VerticalPayload, &S2::VerticalPayload) -> VO,
VO: Clone,
Trait Implementations§
Source§impl<'a, S1, S2, F, VO> Stack for ComposedStack<'a, S1, S2, F, VO>where
S1: Stack,
S2: Stack<Point = S1::CapPt>,
F: Fn(&S1::VerticalPayload, &S2::VerticalPayload) -> VO + Sync + Send,
VO: Clone,
impl<'a, S1, S2, F, VO> Stack for ComposedStack<'a, S1, S2, F, VO>where
S1: Stack,
S2: Stack<Point = S1::CapPt>,
F: Fn(&S1::VerticalPayload, &S2::VerticalPayload) -> VO + Sync + Send,
VO: Clone,
Source§fn base(&self) -> &Self::BaseSieve
fn base(&self) -> &Self::BaseSieve
Returns the base sieve of the composed stack.
§Panics
Panics because ComposedStack does not have direct access to a base sieve.
Source§fn cap(&self) -> &Self::CapSieve
fn cap(&self) -> &Self::CapSieve
Returns the cap sieve of the composed stack.
§Panics
Panics because ComposedStack does not have direct access to a cap sieve.
Source§type VerticalPayload = VO
type VerticalPayload = VO
Vertical arrow payload type.
Source§type BaseSieve = <S1 as Stack>::BaseSieve
type BaseSieve = <S1 as Stack>::BaseSieve
Underlying base Sieve type (horizontal), payload unconstrained.
Source§type CapSieve = <S2 as Stack>::CapSieve
type CapSieve = <S2 as Stack>::CapSieve
Underlying cap Sieve type (horizontal), payload unconstrained.
Source§fn lift<'b>(
&'b self,
p: S1::Point,
) -> Box<dyn Iterator<Item = (S2::CapPt, VO)> + 'b>
fn lift<'b>( &'b self, p: S1::Point, ) -> Box<dyn Iterator<Item = (S2::CapPt, VO)> + 'b>
Returns an iterator over all upward arrows from base point
p to cap points.
Each item is (cap_point, vertical_payload).Source§fn drop<'b>(
&'b self,
q: S2::CapPt,
) -> Box<dyn Iterator<Item = (S1::Point, VO)> + 'b>
fn drop<'b>( &'b self, q: S2::CapPt, ) -> Box<dyn Iterator<Item = (S1::Point, VO)> + 'b>
Returns an iterator over all downward arrows from cap point
q to base points.
Each item is (base_point, vertical_payload).Source§fn add_arrow(
&mut self,
_base: S1::Point,
_cap: S2::CapPt,
_pay: VO,
) -> Result<(), MeshSieveError>
fn add_arrow( &mut self, _base: S1::Point, _cap: S2::CapPt, _pay: VO, ) -> Result<(), MeshSieveError>
Adds a new vertical arrow
base -> cap with associated payload.Source§fn remove_arrow(
&mut self,
_base: S1::Point,
_cap: S2::CapPt,
) -> Result<Option<VO>, MeshSieveError>
fn remove_arrow( &mut self, _base: S1::Point, _cap: S2::CapPt, ) -> Result<Option<VO>, MeshSieveError>
Removes the arrow
base -> cap, returning its payload if present.Auto Trait Implementations§
impl<'a, S1, S2, F, VO> Freeze for ComposedStack<'a, S1, S2, F, VO>where
F: Freeze,
impl<'a, S1, S2, F, VO> RefUnwindSafe for ComposedStack<'a, S1, S2, F, VO>
impl<'a, S1, S2, F, VO> Send for ComposedStack<'a, S1, S2, F, VO>
impl<'a, S1, S2, F, VO> Sync for ComposedStack<'a, S1, S2, F, VO>
impl<'a, S1, S2, F, VO> Unpin for ComposedStack<'a, S1, S2, F, VO>
impl<'a, S1, S2, F, VO> UnsafeUnpin for ComposedStack<'a, S1, S2, F, VO>where
F: UnsafeUnpin,
impl<'a, S1, S2, F, VO> UnwindSafe for ComposedStack<'a, S1, S2, F, VO>
Blanket Implementations§
Source§impl<T> AccumulatePathExt for T
impl<T> AccumulatePathExt for T
fn accumulate_path<O, I>(path: I) -> Owhere
O: Orientation,
I: IntoIterator<Item = O>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more