Trait StepsIter

Source
pub trait StepsIter<O, A, F>: Iterator<Item = PartialStep<O, A, F>> {
    // Provided methods
    fn summarize(self) -> StepsSummary<F>
       where Self: Sized,
             F: Feedback { ... }
    fn take_episodes(self, n: usize) -> TakeEpisodes<Self> 
       where Self: Sized { ... }
    fn take_aligned_steps(
        self,
        min_steps: usize,
        slack: usize,
    ) -> TakeAlignedSteps<Self> 
       where Self: Sized { ... }
    fn fold_transient<B, G>(self, init: B, g: G) -> B
       where G: FnMut(B, TransientStep<'_, O, A, F>) -> B,
             Self: Sized { ... }
    fn for_each_transient<G>(self, g: G)
       where G: FnMut(TransientStep<'_, O, A, F>),
             Self: Sized { ... }
    fn map_transient<B, G>(self, g: G) -> MapTransient<Self, G> 
       where G: FnMut(TransientStep<'_, O, A, G>) -> B,
             Self: Sized { ... }
}
Expand description

An iterator of simulation steps.

Provided Methods§

Source

fn summarize(self) -> StepsSummary<F>
where Self: Sized, F: Feedback,

Consume all steps and produce a summary of the step statistics.

Source

fn take_episodes(self, n: usize) -> TakeEpisodes<Self>
where Self: Sized,

Creates an iterator that yields steps from the first n episodes.

Source

fn take_aligned_steps( self, min_steps: usize, slack: usize, ) -> TakeAlignedSteps<Self>
where Self: Sized,

Creates an iterator of at least min_steps and at most min_steps + slack steps.

Ends on the first episode boundary in this interval.

Source

fn fold_transient<B, G>(self, init: B, g: G) -> B
where G: FnMut(B, TransientStep<'_, O, A, F>) -> B, Self: Sized,

Fold each step viewed as a TransientStep into an accumulator using a closure.

This is the equivalent of Iterator::fold on an iterator of TransientStep except that such an iterator cannot be created without generic associated types.

If the final step.next is Successor::Continue then that step is skipped since the successor observation is missing. The code in this module avoids creating such an abruptly-ending steps iterator but it is possible with the standard iterator methods like take(n).

Source

fn for_each_transient<G>(self, g: G)
where G: FnMut(TransientStep<'_, O, A, F>), Self: Sized,

Call a closure on each step viewed as a TransientStep.

This is the equivalent of Iterator::for_each on an iterator of TransientStep except that such an iterator cannot be created without generic associated types.

If the final step.next is Successor::Continue then that step is skipped since the successor observation is missing. This situation should not arise if using take_episodes or take_aligned_steps.

Source

fn map_transient<B, G>(self, g: G) -> MapTransient<Self, G>
where G: FnMut(TransientStep<'_, O, A, G>) -> B, Self: Sized,

Map each step viewed as a TransientStep.

This is the equivalent of Iterator::map on an iterator of TransientStep except that such an iterator cannot be created without generic associated types.

If the final step.next is Successor::Continue then that step is skipped since the successor observation is missing. This situation should not arise if using take_episodes or take_aligned_steps.

Implementors§

Source§

impl<T, O, A, F> StepsIter<O, A, F> for T
where T: Iterator<Item = PartialStep<O, A, F>>,