40 explicit
Alphabet(std::string_view str) noexcept(false) { this->
insert(str); }
46 explicit Alphabet(
const std::set<Symbol> &symbols)
noexcept(
false) { this->
insert(symbols); }
52 [[nodiscard]]
const std::set<Symbol> &
get_set() const noexcept {
return this->
set_; }
58 [[nodiscard]] std::size_t
size() const noexcept {
return this->
set_.size(); }
67 return this->
set_.contains(symbol);
73 [[nodiscard]]
auto begin() const noexcept {
return this->
set_.begin(); }
78 [[nodiscard]]
auto end() const noexcept {
return this->
set_.end(); }
84 void print(std::ostream &os = std::cout)
const noexcept;
103 template <
class T>
void insert(
const T &data)
noexcept(
false);
108 for (
const auto &s : data)
110 this->set_.insert(
Symbol(s));
Represents the formal alphabet ( or ) of a Turing Machine.
void print(std::ostream &os=std::cout) const noexcept
Prints the alphabet in mathematical set notation format (e.g., "{0, 1}").
auto begin() const noexcept
Returns an iterator to the beginning of the alphabet set.
const std::set< Symbol > & get_set() const noexcept
Getter for the underlying standard set of symbols.
void insert(const T &data) noexcept(false)
Private helper template to genericly process and insert elements into the alphabet.
bool contains(const Symbol &symbol) const noexcept
Checks if a specific Symbol belongs to this alphabet.
friend std::ostream & operator<<(std::ostream &os, const Alphabet &alphabet) noexcept
Overloaded stream insertion operator to print the Alphabet object.
Alphabet() noexcept=default
Default constructor.
std::size_t size() const noexcept
Retrieves the total number of unique symbols currently in the alphabet.
Alphabet(const std::set< Symbol > &symbols) noexcept(false)
Explicit constructor to build an Alphabet from an existing set of Symbols.
auto end() const noexcept
Returns an iterator to the end of the alphabet set.
std::set< Symbol > set_
The unique, sorted collection of symbols composing the alphabet.
Represents a single symbol on the Turing Machine's tape.
Symbol class to represent the symbols on the Turing Machine's tape.