pub struct Actor<Q, A> { /* private fields */ }
Expand description
An Actor is an implementation of a Turing machine with a moving head (TMH).
The model contains the following components:
alpha
: the input alphabethead
: the head of the tape
Implementations§
Source§impl<Q, A> Actor<Q, A>where
Q: RawState,
impl<Q, A> Actor<Q, A>where
Q: RawState,
pub fn new( alpha: impl IntoIterator<Item = A>, state: State<Q>, symbol: usize, ) -> Self
Sourcepub fn from_state(state: State<Q>) -> Self
pub fn from_state(state: State<Q>) -> Self
Constructs a new Actor with the given state; assumes the tape is empty and the head
is located at 0
.
Sourcepub const fn head(&self) -> &Head<Q, usize>
pub const fn head(&self) -> &Head<Q, usize>
returns an immutable reference to the head of the tape
Sourcepub const fn head_mut(&mut self) -> &mut Head<Q, usize>
pub const fn head_mut(&mut self) -> &mut Head<Q, usize>
returns a mutable reference to the head of the tape
Sourcepub fn set_head(&mut self, head: Head<Q, usize>) -> &mut Self
pub fn set_head(&mut self, head: Head<Q, usize>) -> &mut Self
update the current head and return a mutable reference to the actor
Sourcepub fn set_position(&mut self, symbol: usize) -> &mut Self
pub fn set_position(&mut self, symbol: usize) -> &mut Self
updates the current position of the head and returns a mutable reference to the actor
Sourcepub fn set_state(&mut self, state: State<Q>) -> &mut Self
pub fn set_state(&mut self, state: State<Q>) -> &mut Self
updates the current state of the head and returns a mutable reference to the actor
Sourcepub fn set_tape(&mut self, tape: Vec<A>) -> &mut Self
pub fn set_tape(&mut self, tape: Vec<A>) -> &mut Self
update the current tape and return a mutable reference to the actor
Sourcepub fn with_head(self, head: Head<Q, usize>) -> Self
pub fn with_head(self, head: Head<Q, usize>) -> Self
Consumes the current instance and returns a new instance with the given head
Sourcepub fn with_position(self, symbol: usize) -> Self
pub fn with_position(self, symbol: usize) -> Self
Consumes the current instance and returns a new instance with the given position
Sourcepub fn with_state(self, state: State<Q>) -> Self
pub fn with_state(self, state: State<Q>) -> Self
Consumes the current instance and returns a new instance with the given state
Sourcepub fn with_tape<I>(self, alpha: I) -> Selfwhere
I: IntoIterator<Item = A>,
pub fn with_tape<I>(self, alpha: I) -> Selfwhere
I: IntoIterator<Item = A>,
Consumes the current instance and returns a new instance with the given alphabet
Sourcepub fn head_ref(&self) -> Head<&Q, usize>
pub fn head_ref(&self) -> Head<&Q, usize>
returns an instance of the Head with an immutable reference to the state’s inner value
Sourcepub const fn state(&self) -> &State<Q>
pub const fn state(&self) -> &State<Q>
returns an instance of the state with an immutable reference to the inner value
Sourcepub const fn state_mut(&mut self) -> &mut State<Q>
pub const fn state_mut(&mut self) -> &mut State<Q>
returns an instance of the state with a mutable reference to the inner value