|
ADS
Algorithms and Data Structures
|
a STACK realized with a vector of a given capacity More...
#include <ADS/stack/ArrayStack.h>
Public types | |
| using | Item = T |
| the type of the items | |
| using | value_type = T |
| the type of the items | |
| using | size_type = std::size_t |
| the type of the sizes | |
| using | difference_type = std::ptrdiff_t |
| the type of the distances | |
| using | reference = const T & |
| a constant reference | |
| using | const_reference = const T & |
| a constant reference | |
| using | iterator = const T * |
| a constant iterator | |
| using | const_iterator = const T * |
| a constant iterator | |
Public member functions | |
| ArrayStack (std::size_t dim) | |
| the empty stack of at most \( \mathit{dim} \) items | |
| ArrayStack (const ArrayStack &other) | |
| a copy of other, item by item | |
| ArrayStack (ArrayStack &&other) noexcept | |
| the items of other, which is left empty with no capacity | |
| ArrayStack & | operator= (ArrayStack other) noexcept |
| the items of other, by copy and swap | |
| void | swap (ArrayStack &other) noexcept |
| exchanges the items and the capacities with other | |
| bool | empty (void) const |
| true if there is no item, i.e., \( n = 0 \) | |
| const T & | top (void) const |
| the item on top, \( A[ n - 1 ] \) | |
| T | pop (void) |
| removes the item on top and returns it | |
| void | push (const T &v) |
| puts \( v \) on top | |
| std::size_t | size (void) const |
| the number of items, \( n \) | |
| std::size_t | capacity (void) const |
| the maximum number of items, \( c \) | |
| bool | operator== (const ArrayStack &o) const |
| the same items in the same order, whatever the capacities | |
| const_iterator | begin (void) const |
| the iterator on the item at the bottom | |
| const_iterator | end (void) const |
| the iterator past the item on top | |
| const_iterator | cbegin (void) const |
| as begin() | |
| const_iterator | cend (void) const |
| as end() | |
a STACK realized with a vector of a given capacity
| using ADS::ArrayStack< T >::const_iterator = const T * |
a constant iterator
| using ADS::ArrayStack< T >::const_reference = const T & |
a constant reference
| using ADS::ArrayStack< T >::difference_type = std::ptrdiff_t |
the type of the distances
| using ADS::ArrayStack< T >::Item = T |
the type of the items
| using ADS::ArrayStack< T >::iterator = const T * |
a constant iterator
| using ADS::ArrayStack< T >::reference = const T & |
a constant reference
| using ADS::ArrayStack< T >::size_type = std::size_t |
the type of the sizes
| using ADS::ArrayStack< T >::value_type = T |
the type of the items
|
explicit |
the empty stack of at most \( \mathit{dim} \) items
| ADS::ArrayStack< T >::ArrayStack | ( | const ArrayStack< T > & | other | ) |
a copy of other, item by item
|
noexcept |
the items of other, which is left empty with no capacity
|
inlinenodiscard |
the iterator on the item at the bottom
|
nodiscard |
the maximum number of items, \( c \)
|
inlinenodiscard |
as begin()
|
inlinenodiscard |
as end()
|
nodiscard |
true if there is no item, i.e., \( n = 0 \)
|
inlinenodiscard |
the iterator past the item on top
|
noexcept |
the items of other, by copy and swap
|
nodiscard |
the same items in the same order, whatever the capacities
| T ADS::ArrayStack< T >::pop | ( | void | ) |
removes the item on top and returns it
In pseudocode (section 4.3.2), \( A[ 0 .. c - 1 ] \) the vector:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{pop}() \cr 2 & \quad n \gets n - 1 \cr 3 & \quad \textbf{return}\ A[ n ] \end{array}} \]
| void ADS::ArrayStack< T >::push | ( | const T & | v | ) |
puts \( v \) on top
In pseudocode (section 4.3.2):
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{push}( v ) \cr 2 & \quad A[ n ] \gets v;\ n \gets n + 1 \end{array}} \]
|
nodiscard |
the number of items, \( n \)
|
noexcept |
exchanges the items and the capacities with other
|
nodiscard |
the item on top, \( A[ n - 1 ] \)