Skip to main content

SpanHistory

Struct SpanHistory 

Source
pub struct SpanHistory { /* private fields */ }
Expand description

The recent token spans behind the stomach’s boxes: how many tokens the gullet read for each box the stomach’s CycleGuard records. A box period alone cannot tell a loop from a long run over data: every point of a pgf plot[smooth] digests the same content-free boxes (tkz-grapheur’s 11,000-point plot read as a 6-box cycle). A loop repeats the same boxes from the same input; a run over data repeats them from input of varying length. So a detected box period is a loop only when the spans repeat too, with a period that is a multiple of the box period (Self::input_period).

Implementations§

Source§

impl SpanHistory

Source

pub fn reset(&mut self)

Forget every recorded span.

Source

pub fn push(&mut self, span: usize, salt: u64)

Record the span of the newest box, with the register values read for it (take_span_salt): a counter loop reads the same input each period but a new count, so its spans do not repeat.

Source

pub fn input_period(&self, box_period: usize) -> Option<usize>

The smallest period, a multiple of box_period up to MAX_SPAN_PERIOD, with which the recorded spans repeat over the whole history (at least eight repetitions of it); None when they do not.

Trait Implementations§

Source§

impl Default for SpanHistory

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.