pstore2
Public Types | Public Member Functions | List of all members
pstore::array_stack< Ty, Size > Class Template Reference

A simple wrapper for std::array which provides the functionality of a stack, specifically a FILO (first-in, last-out) data structure. More...

#include <array_stack.hpp>

Public Types

using container_type = std::array< Ty, Size >
 
using value_type = typename container_type::value_type
 
using reference = typename container_type::reference
 
using const_reference = typename container_type::const_reference
 
using size_type = typename container_type::size_type
 

Public Member Functions

bool operator== (array_stack const &other) const
 
bool operator!= (array_stack const &other) const
 
container_type::const_iterator begin () const
 Returns an iterator pointing to the first element in the stack.
 
container_type::const_iterator end () const
 Returns an iterator pointing to the past-the-end element in the array container.
 
Capacity
constexpr bool empty () const noexcept
 Checks whether the stack is empty.
 
constexpr size_type size () const noexcept
 Returns the number of elements stored on the stack.
 
constexpr size_t max_size () const noexcept
 Returns the maximum number of elements that the stack is able to hold. More...
 
Element access
reference top () noexcept
 Acceses the top element.
 
const_reference top () const noexcept
 Acceses the top element.
 
Modifiers
void push (value_type const &value)
 Inserts an element at the top of the container. More...
 
void push (value_type &&value)
 Inserts an element at the top of the container. More...
 
void pop ()
 Remove the top element from the stack.
 

Detailed Description

template<class Ty, std::size_t Size>
class pstore::array_stack< Ty, Size >

A simple wrapper for std::array which provides the functionality of a stack, specifically a FILO (first-in, last-out) data structure.

Its interface is close to that of std::stack<>, but an additional class is necessary because std::array<> does not fully meet the requirements of std::stack<>.

Use this class if the stack size is known a priori to be small and of known maximum depth.

Member Function Documentation

◆ max_size()

template<class Ty , std::size_t Size>
constexpr size_t pstore::array_stack< Ty, Size >::max_size ( ) const
inlinenoexcept

Returns the maximum number of elements that the stack is able to hold.

◆ push() [1/2]

template<class Ty , std::size_t Size>
void pstore::array_stack< Ty, Size >::push ( value_type const &  value)
inline

Inserts an element at the top of the container.

Parameters
valueThe value of the element to push

◆ push() [2/2]

template<class Ty , std::size_t Size>
void pstore::array_stack< Ty, Size >::push ( value_type &&  value)
inline

Inserts an element at the top of the container.

Parameters
valueThe value of the element to push

The documentation for this class was generated from the following file: