#[repr(C)]pub struct Head<Q, A> {
pub state: State<Q>,
pub symbol: A,
}Expand description
The Head of a Turing machine is defined to be a two-tuple consisting of a state and a
symbol. Our implementation is generic over both the state and symbol types, allowing for
flexibility in their representation(s).
Fields§
§state: State<Q>§symbol: AImplementations§
Source§impl<Q, A> Head<Q, A>where
Q: RawState,
The core implementation of the Head providing fundamental methods for its manipulation,
including various constructors, accessors, and mutators as well as convienience methods for
converting between representations.
impl<Q, A> Head<Q, A>where
Q: RawState,
The core implementation of the Head providing fundamental methods for its manipulation,
including various constructors, accessors, and mutators as well as convienience methods for
converting between representations.
Sourcepub const fn new(state: Q, symbol: A) -> Head<Q, A>
pub const fn new(state: Q, symbol: A) -> Head<Q, A>
initialize a new instance of the Head given some state and symbol
Sourcepub fn from_state(state: Q) -> Head<Q, A>where
A: Default,
pub fn from_state(state: Q) -> Head<Q, A>where
A: Default,
returns a new instance of the head using the given state and a default symbol
Sourcepub fn from_symbol(symbol: A) -> Head<Q, A>where
Q: Default,
pub fn from_symbol(symbol: A) -> Head<Q, A>where
Q: Default,
returns a new instance of the head using the given symbol and a default state
Sourcepub fn from_tuple(_: (State<Q>, A)) -> Head<Q, A>
pub fn from_tuple(_: (State<Q>, A)) -> Head<Q, A>
Create a new instance from a 2-tuple: (state, symbol)
Sourcepub const fn state_mut(&mut self) -> &mut State<Q>
pub const fn state_mut(&mut self) -> &mut State<Q>
returns a mutable reference to the current State
Sourcepub const fn symbol_mut(&mut self) -> &mut A
pub const fn symbol_mut(&mut self) -> &mut A
returns a mutable reference to the current symbol
Sourcepub fn set_symbol(&mut self, symbol: A)
pub fn set_symbol(&mut self, symbol: A)
updates the current symbol
Sourcepub fn with_state<Q2>(self, state: Q2) -> Head<Q2, A>
pub fn with_state<Q2>(self, state: Q2) -> Head<Q2, A>
consumes the current instance to create another instance with the given state
Sourcepub fn with_symbol<A2>(self, symbol: A2) -> Head<Q, A2>
pub fn with_symbol<A2>(self, symbol: A2) -> Head<Q, A2>
consumes the current instance to create another instance with the given symbol
Sourcepub const fn replace(&mut self, state: State<Q>, symbol: A) -> Head<Q, A>
pub const fn replace(&mut self, state: State<Q>, symbol: A) -> Head<Q, A>
replaces the current values with the given state and symbol, returning the previous
instance of the Head
Sourcepub const fn replace_state(&mut self, state: State<Q>) -> State<Q>
pub const fn replace_state(&mut self, state: State<Q>) -> State<Q>
replace the current state with the given state, returning the
previous state
Sourcepub const fn replace_symbol(&mut self, symbol: A) -> A
pub const fn replace_symbol(&mut self, symbol: A) -> A
replace the current symbol with the given symbol, returning the
previous symbol
Sourcepub const fn swap(&mut self, other: &mut Head<Q, A>)
pub const fn swap(&mut self, other: &mut Head<Q, A>)
swap the state and symbol of the current instance with another
Sourcepub const fn swap_state(&mut self, other: &mut State<Q>)
pub const fn swap_state(&mut self, other: &mut State<Q>)
swap the current state with another
Sourcepub const fn swap_symbol(&mut self, other: &mut A)
pub const fn swap_symbol(&mut self, other: &mut A)
swap the current symbol with another
Sourcepub fn update(&mut self, state: Option<State<Q>>, symbol: Option<A>)
pub fn update(&mut self, state: Option<State<Q>>, symbol: Option<A>)
updates the current State and symbol
Sourcepub const fn as_tuple(&self) -> (&State<Q>, &A)
pub const fn as_tuple(&self) -> (&State<Q>, &A)
returns a reference to the current state and symbol returing a 2-tuple
Sourcepub const fn as_mut_tuple(&mut self) -> (&mut State<Q>, &mut A)
pub const fn as_mut_tuple(&mut self) -> (&mut State<Q>, &mut A)
returns a mutable reference to the current state and symbol as a 2-tuple
Sourcepub fn into_tuple(self) -> (State<Q>, A)
pub fn into_tuple(self) -> (State<Q>, A)
Consumes the head and returns the current state and symbol as a 2-tuple
Sourcepub fn into_rule_with_tail(self, tail: Tail<Q, A>) -> Rule<Q, A>where
Q: RawState,
pub fn into_rule_with_tail(self, tail: Tail<Q, A>) -> Rule<Q, A>where
Q: RawState,
associates the given tail with the current head, returning a new Rule
Sourcepub fn read_tape<T>(self, tape: &[T]) -> Option<&<A as SliceIndex<[T]>>::Output>where
A: SliceIndex<[T]>,
pub fn read_tape<T>(self, tape: &[T]) -> Option<&<A as SliceIndex<[T]>>::Output>where
A: SliceIndex<[T]>,
tries reading the given tape using the head as its coordinates.
Sourcepub const fn view(&self) -> Head<&Q, &A>
pub const fn view(&self) -> Head<&Q, &A>
returns a new head with immutable references to the current state and symbol
Sourcepub const fn view_mut(&mut self) -> Head<&mut Q, &mut A>
pub const fn view_mut(&mut self) -> Head<&mut Q, &mut A>
returns a new head with mutable references to the current state and symbol