#include <infinite_tape.hpp>
Collaboration diagram for infinite_tape< T >:
Public Types | |
enum | direction { left, right, do_nothing, halt_move } |
Public Member Functions | |
infinite_tape () | |
default Constructor. | |
infinite_tape (T new_default_value) | |
construct a tape of start_size with each value set to default value. | |
infinite_tape (typename std::list< T >::size_type new_size, T new_default_value) | |
construct a tape of new_size with each value set to default_value. | |
infinite_tape (const infinite_tape< T > &rhs) | |
copy constructor. | |
const infinite_tape< T > & | operator= (const infinite_tape< T > &rhs) |
assignment operator. | |
~infinite_tape () | |
trivial destructor | |
T | read () const |
Read the value held by the cell under the read-head. | |
void | clear () |
Clears the tape. | |
void | write (T to_write) |
Writes a value to the current location on the tape. | |
void | move (direction which) |
Move the head one position to the left xor to the right of the current position. | |
void | reset_head () |
moves the read-head to the cardinal position. | |
bool | is_blank () const |
Checks if the tape is blank. | |
bool | is_contiguous () const |
Are the symbols on the tape in the format ()*()*()*?. | |
bool | on_blank () const |
Is the read-head on a blank?. | |
bool | symbols_to_direction (direction which) const |
Are there any symbols to the of the read-head?. | |
bool | in_standard_position () const |
Is the tape in standard position?. | |
std::list< T >::size_type | count_occurrences (T to_count) const |
How many occurrences are there of to_count on the tape?. | |
void | show (std::ostream &out) const |
provides the old-style display using a very simple pre-defined inflexible format. | |
template<typename delim_type1, typename delim_type2, typename delim_type3, typename delim_type4, typename delim_type5, typename delim_type6, typename delim_type7, typename delim_type8> void | show (std::ostream &out, const delim_type1 &before_delim, const delim_type2 &between_delim, const delim_type3 &after_delim, const delim_type4 &before_cardinal, const delim_type5 &after_cardinal, const delim_type6 &before_head, const delim_type7 &after_head, const delim_type8 &blank_delim, bool extra_between_delims) const |
wow, could it possibly get more complicated?. | |
void | reset () |
Clears the tape to setting each location to the default value. | |
void | setCurrentLocation (typename std::list< T >::iterator location) |
Sets the read-head to location. | |
T | defaultValue () |
default_value accessor. | |
std::list< T >::iterator | currentLocation () |
Returns the read-head. | |
std::list< T >::iterator | begin () |
Returns the beginning of the tape. | |
std::list< T >::const_iterator | begin () const |
Returns the beginning of the tape. | |
bool | find (typename std::list< T >::iterator find) |
Finds an iterator in the tape. | |
bool | repeatConfigRight (infinite_tape< T > &rhs, typename std::list< T >::iterator lhsLeftBound) |
tests for a simple loop repeat configuration in rhs. | |
bool | repeatConfigLeft (infinite_tape< T > &rhs, typename std::list< T >::iterator lhsRightBound) |
tests for a simple loop repeat configuration in rhs (mirror of repeatConfigRight). | |
void | checkIteratorLeft (typename std::list< T >::iterator leftEdge) |
Expands the tape if the iterator is at the left edge of the tape. | |
void | checkIteratorRight (typename std::list< T >::iterator rightEdge) |
Expands the tape if the iterator is at the right edge of the tape. | |
Protected Member Functions | |
void | tape_check (direction which) |
check to see if tape needs to be expanded and call expansion function if so. | |
void | expand_tape (direction which, typename std::list< T >::size_type how_many) |
Expands the tape. | |
Protected Attributes | |
std::list< T > | tape |
the cells of the tape | |
std::list< T >::iterator | current |
location of read-head on tape | |
std::list< T >::iterator | cardinal |
location of read-head on tape | |
std::list< T >::size_type | counter |
number of moves made counter. | |
T | default_value |
default value when creating a new cell | |
std::list< T >::size_type | non_blank_count |
count the number of non-blank symbols | |
Static Protected Attributes | |
const std::list< T >::size_type | start_size = 101 |
arbitrary start size of tape. |
provides constant amortised time operations assumes small types for storage (e.g. int, bool, etc.) since parameters are passed by value
Definition at line 62 of file infinite_tape.hpp.
|
default Constructor.
Definition at line 71 of file infinite_tape.hpp. |
|
construct a tape of start_size with each value set to default value. set current iterators to the middle element, start at this index, and counter to zero
Definition at line 92 of file infinite_tape.hpp. |
|
construct a tape of new_size with each value set to default_value. set current iterators to the middle element, start at this index, and counter to zero
Definition at line 114 of file infinite_tape.hpp. |
|
copy constructor.
Definition at line 136 of file infinite_tape.hpp. |
|
trivial destructor
Definition at line 179 of file infinite_tape.hpp. |
|
Returns the beginning of the tape.
Definition at line 871 of file infinite_tape.hpp. |
|
Returns the beginning of the tape.
Definition at line 861 of file infinite_tape.hpp. Referenced by tapeBoundsTriple< T >::tapeBoundsTriple(). |
|
Expands the tape if the iterator is at the left edge of the tape.
Definition at line 1087 of file infinite_tape.hpp. |
|
Expands the tape if the iterator is at the right edge of the tape.
Definition at line 1102 of file infinite_tape.hpp. |
|
Clears the tape.
Definition at line 200 of file infinite_tape.hpp. |
|
How many occurrences are there of to_count on the tape?.
Definition at line 376 of file infinite_tape.hpp. |
|
Returns the read-head.
Definition at line 851 of file infinite_tape.hpp. |
|
default_value accessor.
Definition at line 841 of file infinite_tape.hpp. |
|
Expands the tape.
Definition at line 1174 of file infinite_tape.hpp. Referenced by direction::checkIteratorLeft(), direction::checkIteratorRight(), and direction::tape_check(). |
|
Finds an iterator in the tape. used mainly for debugging purposes
Definition at line 883 of file infinite_tape.hpp. |
|
Is the tape in standard position?. (not on_blank()) and is_contiguous() and (symbols_to_direction(left) xor symbols_to_direction(right)); the xor'ing is done by checking that the answers to "are there symbols to the left of the read head?" and "are there symbols to the right of the read head?" are different ... which ensures that there are symbols in exactly one direction and not the other ... sneaky, eh?
Definition at line 365 of file infinite_tape.hpp. |
|
Checks if the tape is blank.
Definition at line 276 of file infinite_tape.hpp. |
|
Are the symbols on the tape in the format ()*()*()*?.
Definition at line 287 of file infinite_tape.hpp. Referenced by direction::in_standard_position(). |
|
Move the head one position to the left xor to the right of the current position. maintains the invariant that the head iterator refers to a valid tape square makes sure that there is tape to the left of the current position to move to then moves
Definition at line 235 of file infinite_tape.hpp. Referenced by transition_result::perform_transition(). |
|
Is the read-head on a blank?.
Definition at line 318 of file infinite_tape.hpp. Referenced by direction::in_standard_position(). |
|
assignment operator.
Definition at line 152 of file infinite_tape.hpp. |
|
Read the value held by the cell under the read-head.
Definition at line 191 of file infinite_tape.hpp. Referenced by transition_result::perform_transition(). |
|
tests for a simple loop repeat configuration in rhs (mirror of repeatConfigRight).
Definition at line 1000 of file infinite_tape.hpp. |
|
tests for a simple loop repeat configuration in rhs.
Definition at line 903 of file infinite_tape.hpp. |
|
Clears the tape to setting each location to the default value.
Definition at line 816 of file infinite_tape.hpp. |
|
moves the read-head to the cardinal position.
Definition at line 263 of file infinite_tape.hpp. |
|
Sets the read-head to location.
Definition at line 831 of file infinite_tape.hpp. |
|
wow, could it possibly get more complicated?. ... no, not complicated, *flexible*! ... each delimiter is of an arbitrary type (call it X_type) but must have an std::ostream& operator<<(ostream&, const X_type&) operator defined
Definition at line 440 of file infinite_tape.hpp. |
|
provides the old-style display using a very simple pre-defined inflexible format.
Definition at line 401 of file infinite_tape.hpp. |
|
Are there any symbols to the of the read-head?.
Definition at line 330 of file infinite_tape.hpp. Referenced by direction::in_standard_position(). |
|
check to see if tape needs to be expanded and call expansion function if so.
Definition at line 1124 of file infinite_tape.hpp. Referenced by direction::move(). |
|
Writes a value to the current location on the tape.
Definition at line 211 of file infinite_tape.hpp. Referenced by transition_result::perform_transition(). |
|
number of moves made counter. allows constant amortised time moves with expansion Definition at line 1207 of file infinite_tape.hpp. Referenced by direction::expand_tape(), direction::infinite_tape(), direction::move(), direction::operator=(), direction::reset(), and direction::tape_check(). |
|
arbitrary start size of tape. odd number chosen so that there are 50 cells to each of the right and left of the cardinal ... just to make the numbers a bit easier Definition at line 1194 of file infinite_tape.hpp. Referenced by direction::infinite_tape(). |