TuringSim
C++ framework to simulate abstract computing models
Public Member Functions | Friends | List of all members
TuringSim::Symbol::TuringStyleConstantSymbolPattern< T > Class Template Reference

A symbol pattern as used by Turing. Such a pattern accept or reject a finite explicit set of symbols. More...

#include <symbol/turingMachineSymbolPattern.h>

Inheritance diagram for TuringSim::Symbol::TuringStyleConstantSymbolPattern< T >:
Inheritance graph
[legend]
Collaboration diagram for TuringSim::Symbol::TuringStyleConstantSymbolPattern< T >:
Collaboration graph
[legend]

Public Member Functions

constexpr TuringStyleConstantSymbolPattern (bool neg)
 Constructs a trivial pattern: a pattern that accepts everything or nothing. More...
 
constexpr TuringStyleConstantSymbolPattern (const T &e)
 Construct a pattern which accept only one symbol. More...
 
constexpr TuringStyleConstantSymbolPattern (const std::set< T > &v)
 Construct a pattern which accept a sequence of symbols. More...
 
constexpr TuringStyleConstantSymbolPattern (const std::set< T > &v, bool b)
 Construct a pattern which accept or reject a sequence of symbols. More...
 
virtual bool match (const T &e) const override
 Test if a letter matches the pattern. More...
 
constexpr bool operator== (const TuringStyleConstantSymbolPattern< T > &other) const
 Equality operator. More...
 
constexpr bool operator!= (const TuringStyleConstantSymbolPattern< T > &other) const
 Non-equality operator. More...
 
constexpr bool operator< (const TuringStyleConstantSymbolPattern< T > &other) const
 Less than operator. Total order. More...
 
- Public Member Functions inherited from TuringSim::Symbol::SymbolPattern< T, void >
 SymbolPattern ()=default
 The default constructor.
 
 SymbolPattern (const SymbolPattern &)=default
 The default copy constructor.
 
 SymbolPattern (SymbolPattern &&)=default
 The default move constructor.
 
SymbolPatternoperator= (const SymbolPattern &)=default
 The default copy assignment operator. More...
 
SymbolPatternoperator= (SymbolPattern &&)=default
 The default move assignment operator. More...
 
virtual ~SymbolPattern ()=default
 The default virtual destructor.
 
virtual bool match (const SymbolType &symbol, const Context &context) const noexcept=0
 Test whether a symbol match the pattern, given a context. More...
 

Friends

template<typename CharT = char, typename Traits = std::char_traits<CharT>>
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &os, const TuringStyleConstantSymbolPattern &pattern)
 Debug printer. More...
 

Additional Inherited Members

- Public Types inherited from TuringSim::Symbol::SymbolPattern< T, void >
typedef T SymbolType
 The type of symbols.
 
typedef void Context
 The type of context.
 

Detailed Description

template<typename T>
class TuringSim::Symbol::TuringStyleConstantSymbolPattern< T >

A symbol pattern as used by Turing. Such a pattern accept or reject a finite explicit set of symbols.

Template Parameters
TThe alphabet.

This kind of pattern has the form \(\{x_1, x_2,\ldots,x_n\}\) or \(\text{not}(\{x_1, x_2,\ldots,x_n\})\) where the \(x_i\) are explicit letters.

Definition at line 17 of file turingMachineSymbolPattern.h.

Constructor & Destructor Documentation

◆ TuringStyleConstantSymbolPattern() [1/4]

template<typename T >
constexpr TuringSim::Symbol::TuringStyleConstantSymbolPattern< T >::TuringStyleConstantSymbolPattern ( bool  neg)
inlineexplicitconstexpr

Constructs a trivial pattern: a pattern that accepts everything or nothing.

Parameters
[in]negtrue if the pattern must accept everything, false if it must reject everything.

Complexity \(\mathcal{O}(1)\)

Definition at line 25 of file turingMachineSymbolPattern.h.

◆ TuringStyleConstantSymbolPattern() [2/4]

template<typename T >
constexpr TuringSim::Symbol::TuringStyleConstantSymbolPattern< T >::TuringStyleConstantSymbolPattern ( const T &  e)
inlineconstexpr

Construct a pattern which accept only one symbol.

Parameters
[in]eThe symbol to accept.

The content of the reference is copied.

Complexity \(\mathcal{O}(1)\)

Definition at line 33 of file turingMachineSymbolPattern.h.

◆ TuringStyleConstantSymbolPattern() [3/4]

template<typename T >
constexpr TuringSim::Symbol::TuringStyleConstantSymbolPattern< T >::TuringStyleConstantSymbolPattern ( const std::set< T > &  v)
inlineconstexpr

Construct a pattern which accept a sequence of symbols.

Parameters
[in]vThe symbols to accept.

The content of the reference is copied.

Complexity \(\mathcal{O}(|\texttt{v}|)\)

Definition at line 41 of file turingMachineSymbolPattern.h.

◆ TuringStyleConstantSymbolPattern() [4/4]

template<typename T >
constexpr TuringSim::Symbol::TuringStyleConstantSymbolPattern< T >::TuringStyleConstantSymbolPattern ( const std::set< T > &  v,
bool  b 
)
inlineconstexpr

Construct a pattern which accept or reject a sequence of symbols.

Parameters
[in]vThe symbols to accept.
[in]bWhether the pattern must reject these symbols.

The content of the reference is copied.

Complexity \(\mathcal{O}(|\texttt{v}|)\)

Definition at line 50 of file turingMachineSymbolPattern.h.

Member Function Documentation

◆ match()

template<typename T >
virtual bool TuringSim::Symbol::TuringStyleConstantSymbolPattern< T >::match ( const T &  e) const
inlineoverridevirtual

Test if a letter matches the pattern.

Parameters
[in]eThe letter to test.
Returns
Whether the letter matches the pattern.

Complexity \(\mathcal{O}(\log|\texttt{v}|)\)

Definition at line 57 of file turingMachineSymbolPattern.h.

◆ operator!=()

template<typename T >
constexpr bool TuringSim::Symbol::TuringStyleConstantSymbolPattern< T >::operator!= ( const TuringStyleConstantSymbolPattern< T > &  other) const
inlineconstexpr

Non-equality operator.

Parameters
[in]otherthe value to compare.
Returns
Whether the comparison is true.

Definition at line 69 of file turingMachineSymbolPattern.h.

◆ operator<()

template<typename T >
constexpr bool TuringSim::Symbol::TuringStyleConstantSymbolPattern< T >::operator< ( const TuringStyleConstantSymbolPattern< T > &  other) const
inlineconstexpr

Less than operator. Total order.

Parameters
[in]otherthe value to compare.
Returns
Whether the comparison is true.

Definition at line 75 of file turingMachineSymbolPattern.h.

◆ operator==()

template<typename T >
constexpr bool TuringSim::Symbol::TuringStyleConstantSymbolPattern< T >::operator== ( const TuringStyleConstantSymbolPattern< T > &  other) const
inlineconstexpr

Equality operator.

Parameters
[in]otherthe value to compare.
Returns
Whether the comparison is true.

Definition at line 63 of file turingMachineSymbolPattern.h.

Friends And Related Function Documentation

◆ operator<<

template<typename T >
template<typename CharT = char, typename Traits = std::char_traits<CharT>>
std::basic_ostream<CharT, Traits>& operator<< ( std::basic_ostream< CharT, Traits > &  os,
const TuringStyleConstantSymbolPattern< T > &  pattern 
)
friend

Debug printer.

Template Parameters
CharTchar type.
Traitsstd::basic_ostream trait.
Parameters
[in,out]osthe output stream.
[in]patternThe pattern to print.
Returns
Updated os.

Definition at line 93 of file turingMachineSymbolPattern.h.


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