|
TuringSim
C++ framework to simulate abstract computing models
|
Observer for the Tape class. More...
#include <memory/tape.h>
Public Member Functions | |
| constexpr | TapeObserver (const Tape< T > &tape) |
| Construct an observer to the tape in parameter. More... | |
| constexpr size_t | getRightSize () const |
| Get the size of the right part of the tape. More... | |
| constexpr size_t | getLeftSize () const |
| Get the size of the left part of the tape. More... | |
| constexpr const std::vector< T > & | getRightTape () const |
| Get the right part of the tape. More... | |
| constexpr const std::vector< T > & | getLeftTape () const |
| Get the left part of the tape. More... | |
| constexpr const std::vector< T > * | getCurrentTape () const |
| Get the current tape. May be the right of the left tape. More... | |
| constexpr size_t | getSizeFactor () const |
| Get the resizing factor of the tape. More... | |
| constexpr const T & | getBlank () const |
| Get the blank symbol. More... | |
| constexpr bool | isOnRight () const |
| Check if the I/O head is on the right half-tape. More... | |
| constexpr size_t | getAbsolutePosition () const |
| Return the current absolute position. More... | |
| constexpr long long int | getPosition () const |
| Return the current position. More... | |
| constexpr const T & | operator[] (long long int position) const |
| Return a const reference to a cell of the tape. More... | |
Observer for the Tape class.
| T | the type of the alphabet of the observed tape. |
The observer allows to access private members. For instance, it can be useful to print the content of the tape. These getters are in the observer because these features does not belongs to the abstract model of the tape.
|
inlineconstexpr |
Construct an observer to the tape in parameter.
| [in] | tape | The tape to observe. It is captured by const reference to track any modification to the tape. |
The behaviour of the observer is undefined (and will probably segfault) once the tape destroyed.
Complexity of \(\mathcal{O}(1)\).
|
inlineconstexpr |
Return the current absolute position.
If the position is non negative positive, the absolution position is the same. But if the position is negative, the absolute position is \(-\texttt{position}-1\)
Complexity of \(\mathcal{O}(1)\).
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Get the resizing factor of the tape.
The resizing factor is the factor by which an half-tape is enlarged when the I/O head hit the end. This resizing method ensures an amortized complexity of \(\mathcal{O}(1)\) for move operations.
Complexity of \(\mathcal{O}(1)\).
|
inlineconstexpr |
|
inlineconstexpr |