|
MTMS main
Modern Turing Machine Simulator
|
Represents a single state in the finite set of states (Q) of the Turing Machine. More...
#include <state.hpp>
Public Member Functions | |
| std::string_view | get_label () const noexcept |
| Getter for the state's unique label. | |
| bool | is_accept () const noexcept |
| Checks if this state is an accepting (final) state. | |
| auto | operator<=> (const State &other) const noexcept |
| Provides lexicographical ordering based solely on the state's label. | |
| bool | operator== (const State &other) const noexcept |
| Compares two states for equality using only their unique identifier. | |
| State () noexcept | |
| Default constructor. | |
| State (std::string label, bool is_accept) noexcept(false) | |
| Explicit constructor to create a named State. | |
Private Attributes | |
| bool | is_accept_ |
| Flag indicating if this is a final/halting state. | |
| std::string | label_ |
| The unique identifier name of the state. | |
Represents a single state in the finite set of states (Q) of the Turing Machine.
This class stores the unique identifier (label) of the state and determines whether it acts as an accepting/halting condition for the machine's execution.
|
inlinenoexcept |
|
inlineexplicit |
Explicit constructor to create a named State.
Takes the label by value and moves it internally to optimize memory allocations.
| label | The unique string identifier for this state (e.g., "q0", "init"). |
| is_accept | Boolean flag indicating if this is an accepting/final state. |
|
inlinenoexcept |
Getter for the state's unique label.
Returning a std::string_view prevents unnecessary string copies.
Definition at line 50 of file state.hpp.
References label_.
Referenced by render_dashboard(), and run_cli_session().
|
inlinenoexcept |
Checks if this state is an accepting (final) state.
Definition at line 56 of file state.hpp.
References is_accept_.
Referenced by run_cli_session(), and TuringMachine::step().
|
inlinenoexcept |
Provides lexicographical ordering based solely on the state's label.
This ordering allows State objects to be stored in ordered associative containers such as std::set while preserving the mathematical uniqueness of states by their identifier.
| other | The state to compare against. |
|
inlinenoexcept |
Compares two states for equality using only their unique identifier.
Within the formal definition of a Turing Machine, each state is uniquely identified by its label. Therefore, the acceptance flag is intentionally ignored during equality comparisons.
| other | The state to compare against. |
Definition at line 68 of file state.hpp.
References label_.
|
private |
Flag indicating if this is a final/halting state.
Definition at line 90 of file state.hpp.
Referenced by is_accept().
|
private |
The unique identifier name of the state.
Definition at line 89 of file state.hpp.
Referenced by get_label(), and operator==().