Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
NormalizeAlphabet.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <string/LinearString.h>
9
10namespace string {
11
12namespace simplify {
13
18public:
28 template < class SymbolType >
30};
31
32template < class SymbolType >
34 char counter = 'a';
35 ext::map<SymbolType, std::string > normalizationData;
36
37 for(const SymbolType& symbol : string.getContent())
38 if(normalizationData.find(symbol) == normalizationData.end())
39 normalizationData.insert ( std::make_pair ( symbol, std::string ( 1, counter ++ ) ) );
40
42 for(const auto& symbol : normalizationData) {
43 alphabet.insert ( symbol.second );
44 }
45
47 for(const SymbolType& symbol : string.getContent()) {
48 data.push_back ( normalizationData.find(symbol)->second );
49 }
50
52}
53
54} /* namespace simplify */
55
56} /* namespace string */
57
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
std::pair< iterator, bool > insert(const T &key, const R &value)
Insert variant with explicit key and value parameters.
Definition: map.hpp:118
auto end() &
Inherited behavior of end for non-const instance.
Definition: map.hpp:215
Definition: set.hpp:44
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Linear string.
Definition: LinearString.h:57
Definition: NormalizeAlphabet.h:17
static string::LinearString< std::string > normalize(const string::LinearString< SymbolType > &string)
Definition: NormalizeAlphabet.h:33
Definition: BarSymbol.cpp:12
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
unsigned counter
Definition: Rename.h:247
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: RandomStringFactory.cpp:12