94 void print(std::ostream &os = std::cout)
const noexcept;
102 friend std::ostream &
operator<<(std::ostream &os,
const Tape &tape)
noexcept;
Represents a formal string (w) consisting of a finite sequence of Symbols.
Represents a single symbol on the Turing Machine's tape.
Simulates the bilateral infinite tape layout of a Turing Machine.
std::map< int, Symbol > cells_
Memory cells mapping coordinates to written Symbols.
void print(std::ostream &os=std::cout) const noexcept
Renders the active layout of the tape and the head tracking to an output stream.
friend std::ostream & operator<<(std::ostream &os, const Tape &tape) noexcept
Overloaded stream insertion operator to allow direct streaming of Tape instances.
Tape() noexcept
Default constructor.
Symbol read() const noexcept
Reads the symbol currently located under the tape head.
void write(Symbol symbol) noexcept(false)
Writes a symbol into the cell currently under the tape head.
void move(Direction dir) noexcept
Shifts the tape head one cell to the left, right or make it stay.
int head_pos_
Current mathematical index coordinate of the head.
Direction enum class representing the possible directions to move on a Turing Machine.
Direction
Specifies the movement direction of the tape head.
@ RIGHT
Move the tape head one cell to the right.
@ LEFT
Move the tape head one cell to the left.
@ STAY
Keep the tape head on the current cell.
String class representing a formal string (sequence of symbols) over an alphabet.
Symbol class to represent the symbols on the Turing Machine's tape.