Transducerdp

Struct Transducerdp 

Source
pub struct Transducerdp<M, T, C>
where M: Monoid, T: Transducer, C: Container<Key = T::State, Value = M::T>,
{ pub dp: C, /* private fields */ }

Fields§

§dp: C

Implementations§

Source§

impl<M, T, C> Transducerdp<M, T, C>
where M: Monoid, T: Transducer, C: Container<Key = T::State, Value = M::T>,

Source

pub fn new<F>(fst: T, init: M::T, factory: F) -> Self
where F: ContainerFactory<Container = C>,

Examples found in repository?
crates/competitive/src/data_structure/transducer.rs (line 107)
102    pub fn with_factory<F>(self, factory: F) -> Transducerdp<M, A, F::Container>
103    where
104        F: ContainerFactory,
105        F::Container: Container<Key = A::State, Value = M::T>,
106    {
107        Transducerdp::new(self.fst, self.init, factory)
108    }
109    pub fn with_hashmap(self) -> Transducerdp<M, A, HashMap<A::State, M::T>>
110    where
111        A::State: Eq + Hash,
112    {
113        Transducerdp::new(self.fst, self.init, HashMapFactory::default())
114    }
115    pub fn with_vecmap<F>(
116        self,
117        key_to_index: F,
118    ) -> Transducerdp<M, A, VecMap<false, A::State, M::T, F>>
119    where
120        F: Fn(&A::State) -> usize + Clone,
121    {
122        Transducerdp::new(self.fst, self.init, VecMapFactory::new(key_to_index))
123    }
124    pub fn with_fixed_vecmap<F>(
125        self,
126        key_to_index: F,
127        len: usize,
128    ) -> Transducerdp<M, A, VecMap<true, A::State, M::T, F>>
129    where
130        F: Fn(&A::State) -> usize + Clone,
131    {
132        Transducerdp::new(
133            self.fst,
134            self.init,
135            FixedVecMapFactory::new(key_to_index, len),
136        )
137    }
Source

pub fn step<S, I, B>(&mut self, sigma: S)
where S: FnMut() -> I, I: IntoIterator<Item = B>, B: Borrow<T::Input>,

Examples found in repository?
crates/competitive/src/data_structure/transducer.rs (line 260)
253    pub fn run<S, I, B>(&mut self, mut sigma: S, len: usize) -> M::T
254    where
255        S: FnMut() -> I,
256        I: IntoIterator<Item = B>,
257        B: Borrow<T::Input>,
258    {
259        for _ in 0..len {
260            self.step(&mut sigma);
261        }
262        self.fold_accept()
263    }
Source

pub fn step_effect<S, I, B, F>(&mut self, sigma: S, effect: F)
where S: FnMut() -> I, I: IntoIterator<Item = B>, B: Borrow<T::Input>, F: FnMut(&M::T, &T::Output) -> M::T,

Examples found in repository?
crates/competitive/src/data_structure/transducer.rs (line 272)
264    pub fn run_effect<S, I, B, F>(&mut self, mut sigma: S, len: usize, mut effect: F) -> M::T
265    where
266        S: FnMut() -> I,
267        I: IntoIterator<Item = B>,
268        B: Borrow<T::Input>,
269        F: FnMut(&M::T, &T::Output) -> M::T,
270    {
271        for _ in 0..len {
272            self.step_effect(&mut sigma, &mut effect);
273        }
274        self.fold_accept()
275    }
Source

pub fn fold_accept(&self) -> M::T

Examples found in repository?
crates/competitive/src/data_structure/transducer.rs (line 262)
253    pub fn run<S, I, B>(&mut self, mut sigma: S, len: usize) -> M::T
254    where
255        S: FnMut() -> I,
256        I: IntoIterator<Item = B>,
257        B: Borrow<T::Input>,
258    {
259        for _ in 0..len {
260            self.step(&mut sigma);
261        }
262        self.fold_accept()
263    }
264    pub fn run_effect<S, I, B, F>(&mut self, mut sigma: S, len: usize, mut effect: F) -> M::T
265    where
266        S: FnMut() -> I,
267        I: IntoIterator<Item = B>,
268        B: Borrow<T::Input>,
269        F: FnMut(&M::T, &T::Output) -> M::T,
270    {
271        for _ in 0..len {
272            self.step_effect(&mut sigma, &mut effect);
273        }
274        self.fold_accept()
275    }
Source

pub fn map_fold_accept<U, F, D>(&self, f: F, map: D) -> D
where F: FnMut(&T::State) -> U, D: Container<Key = U, Value = M::T>,

Source

pub fn run<S, I, B>(&mut self, sigma: S, len: usize) -> M::T
where S: FnMut() -> I, I: IntoIterator<Item = B>, B: Borrow<T::Input>,

Source

pub fn run_effect<S, I, B, F>( &mut self, sigma: S, len: usize, effect: F, ) -> M::T
where S: FnMut() -> I, I: IntoIterator<Item = B>, B: Borrow<T::Input>, F: FnMut(&M::T, &T::Output) -> M::T,

Trait Implementations§

Source§

impl<M, T, C> Clone for Transducerdp<M, T, C>
where M: Monoid + Clone, T: Transducer + Clone, C: Container<Key = T::State, Value = M::T> + Clone,

Source§

fn clone(&self) -> Transducerdp<M, T, C>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<M, T, C> Debug for Transducerdp<M, T, C>
where M: Monoid, T: Transducer + Debug, T::State: Debug, M::T: Debug, C: Container<Key = T::State, Value = M::T> + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<M, T, C> Freeze for Transducerdp<M, T, C>
where T: Freeze, C: Freeze,

§

impl<M, T, C> RefUnwindSafe for Transducerdp<M, T, C>

§

impl<M, T, C> Send for Transducerdp<M, T, C>
where T: Send, C: Send,

§

impl<M, T, C> Sync for Transducerdp<M, T, C>
where T: Sync, C: Sync,

§

impl<M, T, C> Unpin for Transducerdp<M, T, C>
where T: Unpin, C: Unpin,

§

impl<M, T, C> UnwindSafe for Transducerdp<M, T, C>
where T: UnwindSafe, C: UnwindSafe,

Blanket Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.