Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
ranked_symbol.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/tuple>
9
10#include <core/normalize.hpp>
11
13
14namespace common {
15
19template < class SymbolType = DefaultSymbolType >
21 SymbolType m_symbol;
22 size_t m_rank;
23
24public:
30 explicit ranked_symbol ( SymbolType symbol, size_t rank );
31
35 const SymbolType & getSymbol ( ) const &;
36
40 SymbolType && getSymbol ( ) &&;
41
45 const size_t & getRank ( ) const &;
46
50 size_t getRank ( ) &&;
51
52 auto operator <=> ( const ranked_symbol & other ) const {
53 return ext::tie ( m_symbol, m_rank ) <=> ext::tie ( other.m_symbol, other.m_rank );
54 }
55
56 bool operator == ( const ranked_symbol & other ) const {
57 return ext::tie ( m_symbol, m_rank ) == ext::tie ( other.m_symbol, other.m_rank );
58 }
59
61 ++ m_symbol;
62
63 return *this;
64 }
65};
66
67template < class SymbolType >
68ranked_symbol < SymbolType >::ranked_symbol(SymbolType symbol, size_t rank) : m_symbol(std::move(symbol)), m_rank(rank) {
69
70}
71
72template < class SymbolType >
74 return m_symbol;
75}
76
77template < class SymbolType >
79 return std::move ( m_symbol );
80}
81
82template < class SymbolType >
83const size_t & ranked_symbol < SymbolType >::getRank ( ) const & {
84 return m_rank;
85}
86
87template < class SymbolType >
89 return m_rank;
90}
91
92template < class SymbolType >
94 out << "(ranked_symbol " << symbol.getSymbol ( ) << " #" << symbol.getRank ( ) << ")";
95 return out;
96}
97
98} /* namespace common */
99
Definition: ranked_symbol.hpp:20
ranked_symbol< SymbolType > & operator++()
Definition: ranked_symbol.hpp:60
ranked_symbol(SymbolType symbol, size_t rank)
Definition: ranked_symbol.hpp:68
auto operator<=>(const ranked_symbol &other) const
Definition: ranked_symbol.hpp:52
const SymbolType & getSymbol() const &
Definition: ranked_symbol.hpp:73
bool operator==(const ranked_symbol &other) const
Definition: ranked_symbol.hpp:56
const size_t & getRank() const &
Definition: ranked_symbol.hpp:83
Definition: ostream.h:14
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
Definition: Permutation.hpp:18
ext::ostream & operator<<(ext::ostream &out, const common::ranked_symbol< SymbolType > &symbol)
Definition: ranked_symbol.hpp:93
constexpr tuple< Elements &... > tie(Elements &... args) noexcept
Helper of extended tuple of references construction. The tuple is constructed to reffer to values in ...
Definition: tuple.hpp:218