Template Class MultiStack

Nested Relationships

Nested Types

Class Documentation

template<class T>
class MultiStack

k stacks sharing a vector of linked cells

Public Types

using Item = T

the type of the items

using value_type = T
using const_iterator = IndexIterator<Cell, T, &Cell::below, &Cell::value>

Public Functions

explicit MultiStack(int k)

k empty stacks

Pre:

k > 0

int stacks(void) const
bool empty(int i) const
Pre:

0 <= i < k

int size(int i) const
Pre:

0 <= i < k

const T &top(int i) const
Pre:

0 <= i < k, the stack i is not empty

void push(int i, const T &v)

v on the stack i; v may be an item of the stacks, e.g., top( j )

Pre:

0 <= i < k

Post:

one item more in the stack i

T pop(int i)
Pre:

0 <= i < k, the stack i is not empty

Post:

one item less in the stack i

inline std::ranges::subrange<const_iterator> stack(int i) const

the items of the stack i, the top first

Pre:

0 <= i < stacks()