Program Listing for File SequenceStack.h
↰ Return to documentation for file (ADS/stack/SequenceStack.h)
/*--------------------------------------------------------------------------*/
/*-------------------------- File SequenceStack.h --------------------------*/
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/*----------------------------- DEFINITIONS --------------------------------*/
/*--------------------------------------------------------------------------*/
#ifndef __ADS_SequenceStack
#define __ADS_SequenceStack
/* self-identification: #endif constant */
/*--------------------------------------------------------------------------*/
/*------------------------------ INCLUDES ----------------------------------*/
/*--------------------------------------------------------------------------*/
#include "ADS/ADT.h"
#include "ADS/Contract.h"
#include <ranges>
/*--------------------------------------------------------------------------*/
/*--------------------------- NAMESPACE ------------------------------------*/
/*--------------------------------------------------------------------------*/
namespace ADS {
/*--------------------------------------------------------------------------*/
/*-------------------------- CLASS SequenceStack ---------------------------*/
/*--------------------------------------------------------------------------*/
template< Sequence S >
class SequenceStack {
/*--------------------------------------------------------------------------*/
public:
using Item = typename S::Item;
[[nodiscard]] bool empty( void ) const;
[[nodiscard]] const Item & top( void ) const;
Item pop( void );
void push( const Item & v );
[[nodiscard]] bool operator==( const SequenceStack & o ) const = default;
/*------------------------- THE STANDARD INTERFACE -------------------------*/
// a constant view of the items from the top to the bottom, with the
// iterators of the sequence, when it has them
[[nodiscard]] auto begin( void ) const
requires std::ranges::range< const S > {
return( std::ranges::cbegin( f_s ) );
}
[[nodiscard]] auto end( void ) const
requires std::ranges::range< const S > {
return( std::ranges::cend( f_s ) );
}
/*--------------------------------------------------------------------------*/
private:
S f_s;
}; // end( class SequenceStack )
/*--------------------------------------------------------------------------*/
} // end( namespace ADS )
/*--------------------------------------------------------------------------*/
/*-------------------------- IMPLEMENTATION --------------------------------*/
/*--------------------------------------------------------------------------*/
#include "ADS/stack/impl/SequenceStack.tpp"
/*--------------------------------------------------------------------------*/
#endif /* SequenceStack.h included */
/*--------------------------------------------------------------------------*/
/*------------------------ End File SequenceStack.h ------------------------*/
/*--------------------------------------------------------------------------*/