|
ADS
Algorithms and Data Structures
|
SequenceStack is the STACK [see ADT.h] simulated with the operations of any SEQUENCE, the top being its first item: More...
#include "ADS/ADT.h"#include "ADS/Contract.h"#include <ranges>#include "ADS/stack/impl/SequenceStack.tpp"Go to the source code of this file.
Classes | |
| class | ADS::SequenceStack< S > |
| a STACK simulated with the operations of a SEQUENCE S, the top first More... | |
Namespaces | |
| namespace | ADS |
SequenceStack is the STACK [see ADT.h] simulated with the operations of any SEQUENCE, the top being its first item:
\[ \mathrm{top}() = \mathrm{read}( \mathrm{head}() ) \qquad \mathrm{pop}() = \mathrm{remove}( \mathrm{head}() ) \qquad \mathrm{push}( v ) = \mathrm{insert}( \mathrm{head}() , v ) \; , \]
which takes \( O( 1 ) \) time on a list with pointers, even a singly linked one (exercise 4.6), and has no capacity.
The contracts [see Contract.h]: top() and pop() need a stack that is not empty, and push() ensures one that is not. The operations are defined in SequenceStack.tpp.