Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
IndexesNormalize.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/vector>
9#include <alib/tuple>
10#include <alib/set>
11#include <alib/trie>
12#include <optional>
13
15
16namespace indexes {
17
22 template < class SymbolType, class ValueType >
25
26 for ( std::pair < SymbolType, ext::trie < SymbolType, ValueType > > && child : ext::make_mover ( node.getChildren ( ) ) ) {
27 children.insert ( std::make_pair ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( child.first ) ), normalizeTrieInner ( std::move ( child.second ) ) ) );
28 }
29
30 return ext::trie < DefaultSymbolType, ValueType > ( std::move ( node.getData ( ) ), std::move ( children ) );
31 }
32
33 template < class SymbolType, class ValueType >
34 static ext::trie < common::ranked_symbol < DefaultSymbolType >, ValueType > normalizeRankedTrieInner ( ext::trie < common::ranked_symbol < SymbolType >, ValueType > && node ) {
36
37 for ( std::pair < common::ranked_symbol < SymbolType >, ext::trie < common::ranked_symbol < SymbolType >, ValueType > > && child : ext::make_mover ( node.getChildren ( ) ) ) {
38 children.insert ( std::make_pair ( alphabet::SymbolNormalize::normalizeRankedSymbol ( std::move ( child.first ) ), normalizeRankedTrieInner ( std::move ( child.second ) ) ) );
39 }
40
41 return ext::trie < common::ranked_symbol < DefaultSymbolType >, ValueType > ( std::move ( node.getData ( ) ), std::move ( children ) );
42 }
43
44public:
45 template < class SymbolType >
47
48 template < class SymbolType >
49 static ext::trie < DefaultSymbolType, std::optional < unsigned > > normalizeTrie ( ext::trie < SymbolType, std::optional < unsigned > > && trie );
50
51 template < class SymbolType >
53
54 template < class SymbolType >
55 static ext::trie < common::ranked_symbol < DefaultSymbolType >, std::optional < unsigned > > normalizeRankedTrie ( ext::trie < common::ranked_symbol < SymbolType >, std::optional < unsigned > > && trie );
56
57};
58
59template < class SymbolType >
61 return normalizeTrieInner ( std::move ( trie ) ) ;
62}
63
64template < class SymbolType >
66 return normalizeTrieInner ( std::move ( trie ) ) ;
67}
68
69template < class SymbolType >
71 return normalizeRankedTrieInner ( std::move ( trie ) ) ;
72}
73
74template < class SymbolType >
76 return normalizeRankedTrieInner ( std::move ( trie ) ) ;
77}
78
79} /* namespace indexes */
80
static common::ranked_symbol< DefaultSymbolType > normalizeRankedSymbol(common::ranked_symbol< SymbolType > &&symbol)
Definition: SymbolNormalize.h:81
static DefaultSymbolType normalizeSymbol(SymbolType &&symbol)
Definition: SymbolNormalize.h:68
Definition: ranked_symbol.hpp:20
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
Class introducing a trie with interface trying to be close to the interface of standard library conta...
Definition: trie.hpp:47
Definition: IndexesNormalize.h:21
static ext::trie< DefaultSymbolType, unsigned > normalizeTrie(ext::trie< SymbolType, unsigned > &&trie)
Definition: IndexesNormalize.h:60
static ext::trie< common::ranked_symbol< DefaultSymbolType >, unsigned > normalizeRankedTrie(ext::trie< common::ranked_symbol< SymbolType >, unsigned > &&trie)
Definition: IndexesNormalize.h:70
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
reference_mover< T > make_mover(T &param)
Move adaptor construction function specialized to lvalue reference parameter.
Definition: iterator.hpp:468
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: CompressedBitParallelTreeIndex.h:40
Definition: Node.cpp:11