|
TuringSim
C++ framework to simulate abstract computing models
|
Class to represent a stack memory. More...
#include <memory/stack.h>


Public Member Functions | |
| constexpr | Stack () |
| Construct an empty stack. | |
| constexpr | Stack (const Stack< T > &other) |
| Copy a stack. More... | |
| constexpr | Stack (Stack< T > &&other) |
| Move a stack. More... | |
| constexpr Stack< T > & | operator= (const Stack< T > &other) |
| Copy a stack. More... | |
| constexpr Stack< T > & | operator= (Stack< T > &&other) |
| Move a stack. More... | |
| ~Stack ()=default | |
| Destruct the stack. | |
| constexpr void | push (const T &symbol) |
| Push an element on the stack. More... | |
| constexpr void | push (T &&symbol) |
| Push an element on the stack. More... | |
| constexpr void | pushs (const std::vector< T > &symbol) |
| Push multiple elements on the stack. More... | |
| constexpr void | pushs (std::vector< T > &&symbol) |
| Push multiple elements on the stack. More... | |
| const T & | top () const |
| Get the top element of the stack. More... | |
| std::optional< T > | top_opt () const |
| Get the top element of the stack. More... | |
| std::vector< T > | tops (size_t nb) const |
| Get the top elements of the stack. More... | |
| std::optional< std::vector< T > > | tops_opt (size_t nb) const |
| Get the top elements of the stack. More... | |
| void | pop () |
| Pop the top element of the stack. More... | |
| void | pops (size_t nb) |
| Pop multiple top elements of the stack. More... | |
| constexpr bool | empty () const noexcept |
| Test if the stack is empty. More... | |
| void | assertNonEmpty () const |
| Test if the stack is empty. More... | |
Public Member Functions inherited from TuringSim::Memory::MemoryStructure< T, Stack< T >, StackObserver< T >, StackModifier< T > > | |
| ~MemoryStructure () | |
| Release current observers and modifier. | |
| const std::set< Observer * > & | getObservers () const noexcept |
| Gets the set of observers. More... | |
| const std::optional< Modifier * > & | getModifier () const noexcept |
| Gets the optional modifier. More... | |
Static Public Attributes | |
| static constexpr size_t | MinAllocatedStackSize = 10 |
| The size allocated when constructing a stack. More... | |
Friends | |
| class | StackObserver< T > |
| Observer for the Stack class. | |
| class | StackModifier< T > |
| Modifier for the Stack class. | |
Additional Inherited Members | |
Public Types inherited from TuringSim::Memory::MemoryStructure< T, Stack< T >, StackObserver< T >, StackModifier< T > > | |
| typedef StackObserver< T > | Observer |
| The type of observers. | |
| typedef StackModifier< T > | Modifier |
| The type of modifiers. | |
| typedef T | SymbolType |
| The alphabet type. More... | |
Public Attributes inherited from TuringSim::Memory::MemoryStructure< T, Stack< T >, StackObserver< T >, StackModifier< T > > | |
| friend | Observer |
| Observer class. | |
| friend | Modifier |
| Modifier class. | |
Class to represent a stack memory.
| T | Type representing the working alphabet |
Unlike TuringSim::Memory::Tape, Stack can automatically free memory when the used segment is small enough compared to the allocated size.
|
constexpr |
|
constexpr |
| void TuringSim::Memory::Stack::Stack< T >::assertNonEmpty |
|
constexprnoexcept |
|
constexpr |
|
constexpr |
| void TuringSim::Memory::Stack::Stack< T >::pop |
| void TuringSim::Memory::Stack::Stack< T >::pops | ( | size_t | nb | ) |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
| const T & TuringSim::Memory::Stack::Stack< T >::top |
Get the top element of the stack.
| EmptyStackException | if the stack is empty. |
The reference is valid as long as it is not popped from the stack, and the stack is not reallocated: either free is disabled or the stack is not modified.
| std::optional< T > TuringSim::Memory::Stack::Stack< T >::top_opt |
| std::vector< T > TuringSim::Memory::Stack::Stack< T >::tops | ( | size_t | nb | ) | const |
| std::optional< std::vector< T > > TuringSim::Memory::Stack::Stack< T >::tops_opt | ( | size_t | nb | ) | const |
|
staticconstexpr |