Template Class ArrayStack

Class Documentation

template<class T>
class ArrayStack

a STACK realized with a vector of a given capacity

Public Types

using Item = T

the type of the items

using value_type = T
using size_type = std::size_t
using difference_type = std::ptrdiff_t
using reference = const T&
using const_reference = const T&
using iterator = const T*
using const_iterator = const T*

Public Functions

explicit ArrayStack(std::size_t dim)

the empty stack of at most dim items

ArrayStack(const ArrayStack &other)
ArrayStack(ArrayStack &&other) noexcept

the items of other, which is left empty with no capacity

ArrayStack &operator=(ArrayStack other) noexcept
void swap(ArrayStack &other) noexcept
bool empty(void) const
const T &top(void) const

the item on top

Pre:

the stack is not empty

T pop(void)

removes the item on top and returns it

Pre:

the stack is not empty

Post:

one item less, the old top returned

void push(const T &v)

puts v on top

Pre:

the stack is not full

Post:

one item more, v on top

std::size_t size(void) const

the number of items

std::size_t capacity(void) const

the maximum number of items

bool operator==(const ArrayStack &o) const

the same items in the same order, whatever the capacities

inline const_iterator begin(void) const
inline const_iterator end(void) const
inline const_iterator cbegin(void) const
inline const_iterator cend(void) const