Skip to main content

ComposedStack

Struct ComposedStack 

Source
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: F

Implementations§

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,

Source

pub fn new(lower: &'a S1, upper: &'a S2, compose_payload: F) -> Self

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,

Source§

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

Returns the cap sieve of the composed stack.

§Panics

Panics because ComposedStack does not have direct access to a cap sieve.

Source§

type Point = <S1 as Stack>::Point

Base mesh point identifier.
Source§

type CapPt = <S2 as Stack>::CapPt

Cap mesh point identifier.
Source§

type VerticalPayload = VO

Vertical arrow payload type.
Source§

type BaseSieve = <S1 as Stack>::BaseSieve

Underlying base Sieve type (horizontal), payload unconstrained.
Source§

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>

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>

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>

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>

Removes the arrow base -> cap, returning its payload if present.
Source§

fn base_mut(&mut self) -> Result<&mut Self::BaseSieve, MeshSieveError>

Returns a mutable reference to the underlying base Sieve.
Source§

fn cap_mut(&mut self) -> Result<&mut Self::CapSieve, MeshSieveError>

Returns a mutable reference to the underlying cap Sieve.

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>
where F: Send, S1: Sync, S2: Sync, VO: Send,

§

impl<'a, S1, S2, F, VO> Sync for ComposedStack<'a, S1, S2, F, VO>
where F: Sync, S1: Sync, S2: Sync, VO: Sync,

§

impl<'a, S1, S2, F, VO> Unpin for ComposedStack<'a, S1, S2, F, VO>
where F: Unpin, VO: Unpin,

§

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

Source§

fn accumulate_path<O, I>(path: I) -> O
where O: Orientation, I: IntoIterator<Item = O>,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.