|
ADS
Algorithms and Data Structures
|
a STACK simulated with the operations of a SEQUENCE S, the top first More...
#include <ADS/stack/SequenceStack.h>
Public types | |
| using | Item = typename S::Item |
| the type of the items | |
Public member functions | |
| bool | empty (void) const |
| true if there is no item, empty() of the sequence | |
| const Item & | top (void) const |
| the item on top, read( head() ) | |
| Item | pop (void) |
| removes the item on top and returns it, remove( head() ) | |
| void | push (const Item &v) |
| puts \( v \) on top, insert( head() , v ) | |
| bool | operator== (const SequenceStack &o) const =default |
| the same items in the same order, those of the sequences | |
| auto | begin (void) const |
| the iterator of the sequence on the item on top | |
| auto | end (void) const |
| the iterator of the sequence past the item at the bottom | |
a STACK simulated with the operations of a SEQUENCE S, the top first
| using ADS::SequenceStack< S >::Item = typename S::Item |
the type of the items
|
inlinenodiscard |
the iterator of the sequence on the item on top
|
nodiscard |
true if there is no item, empty() of the sequence
|
inlinenodiscard |
the iterator of the sequence past the item at the bottom
|
nodiscarddefault |
the same items in the same order, those of the sequences
| Item ADS::SequenceStack< S >::pop | ( | void | ) |
removes the item on top and returns it, remove( head() )
In pseudocode (section 4.3.1), the item copied before the removal, since a SEQUENCE does not hand out the item it removes:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{pop}() \cr 2 & \quad v \gets S.\mathrm{read}( S.\mathrm{head}() ) \cr 3 & \quad S.\mathrm{remove}( S.\mathrm{head}() ) \cr 4 & \quad \textbf{return}\ v \end{array}} \]
| void ADS::SequenceStack< S >::push | ( | const Item & | v | ) |
puts \( v \) on top, insert( head() , v )
In pseudocode (section 4.3.1):
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{push}( v ) \cr 2 & \quad S.\mathrm{insert}( S.\mathrm{head}() , v ) \end{array}} \]
|
nodiscard |
the item on top, read( head() )
In pseudocode (section 4.3.1), \( S \) the sequence:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{top}() \cr 2 & \quad \textbf{return}\ S.\mathrm{read}( S.\mathrm{head}() ) \end{array}} \]