Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
SuffixAutomatonFactors.h
Go to the documentation of this file.
1
6#pragma once
7
9#include <string/LinearString.h>
10
11#include <automaton/run/Run.h>
12#
13
14namespace stringology {
15
16namespace query {
17
25public:
32 template < class SymbolType >
34};
35
36template < class SymbolType >
38 unsigned backboneLength = suffixAutomaton.getBackboneLength ( );
39
40 ext::tuple < bool, unsigned, ext::set < unsigned > > run = automaton::run::Run::calculateState ( suffixAutomaton.getAutomaton ( ), string );
41 if ( ! std::get < 0 > ( run ) )
42 return { };
43
44 std::deque < std::pair < unsigned, unsigned > > open = { { std::get < 1 > ( run ), 0u } };
46 while ( ! open.empty ( ) ) {
47 std::pair < unsigned, unsigned > cur = std::move ( open.back ( ) );
48 open.pop_back ( );
49
50 if ( suffixAutomaton.getAutomaton ( ).getFinalStates ( ).count ( cur.first ) )
51 tmp.push_back ( cur.second );
52
53 for ( const auto & transition : suffixAutomaton.getAutomaton ( ).getTransitionsFromState ( cur.first ) )
54 open.emplace_back ( transition.second, cur.second + 1 );
55 }
56
58 for ( unsigned dist : tmp )
59 res.insert ( backboneLength - dist - string.getContent ( ).size ( ) );
60
61 return res;
62}
63
64} /* namespace query */
65
66} /* namespace stringology */
67
Definition: set.hpp:44
Class extending the tuple class from the standard library. Original reason is to allow printing of th...
Definition: tuple.hpp:42
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Suffix automaton string index. Automaton representation of all suffixes. The automaton is general det...
Definition: SuffixAutomaton.h:50
unsigned getBackboneLength() const
Definition: SuffixAutomaton.h:116
const automaton::DFA< SymbolType, unsigned > & getAutomaton() const &
Definition: SuffixAutomaton.h:175
Linear string.
Definition: LinearString.h:57
Definition: SuffixAutomatonFactors.h:24
static ext::set< unsigned > query(const indexes::stringology::SuffixAutomaton< SymbolType > &suffixAutomaton, const string::LinearString< SymbolType > &string)
Definition: SuffixAutomatonFactors.h:37
return res
Definition: MinimizeByPartitioning.h:145
Definition: ArithmeticCompression.h:18