34 class ExactSubtreeRepeatsAux {
41 template <
class SymbolType >
49 template <
class SymbolType >
57 template <
class SymbolType >
65 template <
class SymbolType >
78 unsigned alphabetSize;
89 template <
class SymbolType >
99 static void assignLevel (
ext::deque < unsigned > S,
unsigned l, ExactSubtreeRepeats::ExactSubtreeRepeatsAux & aux );
110 template <
class SymbolType >
118 template <
class SymbolType >
122template <
class SymbolType >
126 this->treeSize = symbols.size ( );
142template <
class SymbolType >
146 this->alphabetSize = 0;
148 for (
auto it = symbols.begin ( ); it != symbols.end ( ); it++ ) {
149 auto search = mu_map.find (
ext::make_pair ( it->getSymbol ( ), it->getRank ( ) ) );
151 if ( search == mu_map.
end ( ) ) {
153 mu.push_back ( this->alphabetSize );
154 this->alphabetSize += 1;
156 mu.push_back ( search->second );
162 for (
auto it = mu_map.
begin ( ); it != mu_map.
end ( ); it++ )
174template <
class SymbolType >
178 std::stack < unsigned > RP;
180 for (
unsigned i = 0;
i < symbols.size ( ); ++
i ) {
181 for (
unsigned j = 0; j < symbols[
i].getRank ( ); ++j ) {
193 for (
unsigned parent : P )
200template <
class SymbolType >
204 std::stack < unsigned > RH;
206 for (
unsigned i = 0;
i < symbols.size ( ); ++
i ) {
207 if ( symbols[
i].getRank ( ) == 0 ) {
213 for (
unsigned j = 0; j < symbols[
i].getRank ( ); ++j ) {
214 unsigned p = RH.top ( );
231 for (
unsigned height : H )
238template <
class SymbolType >
242 std::stack < unsigned > RFC;
244 for (
unsigned i = 0;
i < symbols.size ( ); ++
i ) {
245 if ( symbols[
i].getRank ( ) == 0 ) {
248 for (
unsigned j = 0; j < symbols[
i].getRank ( ) - 1; ++j ) {
249 unsigned r = RFC.top ( );
254 unsigned r = RFC.top ( );
265 for (
bool firstChild : FC )
272template <
class SymbolType >
275 std::queue < unsigned > Q1;
276 std::queue < unsigned > Q2;
277 std::queue < ext::tuple < ext::deque < unsigned >, unsigned,
int > > Q3;
284 while ( !S.empty ( ) ) {
285 unsigned i = S.front ( );
289 if ( aux.T[r] != 0 ) {
290 std::get < 0 > ( En[aux.T[r]] ).push_back (
i );
292 if ( ! Bn [ aux.T [ r ] ] ) {
294 std::get < 1 > ( En[aux.T[r]] ) = l + aux.TL[r];
295 std::get < 2 > ( En[aux.T[r]] ) = ac - 1;
296 Q1.push ( aux.T[r] );
299 unsigned v = aux.mu[r];
300 std::get < 0 > ( Es[v] ).push_back (
i );
304 std::get < 1 > ( Es[v] ) = l + 1;
305 std::get < 2 > ( Es[v] ) = ac + symbols[r].getRank ( ) - 1;
311 while ( !Q1.empty ( ) ) {
312 unsigned k = Q1.front ( );
314 Q3.push ( std::move ( En[k] ) );
325 while ( !Q2.empty ( ) ) {
326 unsigned k = Q2.front ( );
328 Q3.push ( std::move ( Es[k] ) );
339 while ( !Q3.empty ( ) ) {
340 ext::tie ( S, l, ac ) = std::move ( Q3.front ( ) );
350 for (
unsigned j : S ) {
355 ExactSubtreeRepeats::assignLevel ( std::move ( S ), l, aux );
357 ExactSubtreeRepeats::partition ( std::move ( S ), l, ac, symbols, aux );
362template <
class SymbolType >
365 ExactSubtreeRepeats::ExactSubtreeRepeatsAux aux = ExactSubtreeRepeats::ExactSubtreeRepeatsAux ( symbols );
370 std::queue < unsigned > Q5;
372 for (
unsigned i = 0;
i < aux.treeSize; ++
i ) {
373 if ( symbols[
i].getRank ( ) == 0 ) {
374 unsigned k = aux.mu[
i];
381 As[k].push_back (
i );
400 for (
unsigned i = 0;
i < As.size ( ); ++
i )
401 if ( !As[
i].empty ( ) )
407 while ( !Q5.empty ( ) ) {
408 unsigned k = Q5.front ( );
416 ExactSubtreeRepeats::assignLevel ( std::move ( As[k] ), 1, aux );
419 for (
unsigned i = 1;
i <= aux.H.back ( );
i++ )
420 while ( !aux.LA[
i].empty ( ) ) {
421 ExactSubtreeRepeats::partition ( std::move ( aux.LA[
i].front ( ).first ), aux.LA[
i].front ( ).second, 0, symbols, aux );
433 unsigned curr_repeat = 0;
435 for (
const auto & repeat : aux.found_repeats ) {
436 for (
unsigned s : repeat.first )
437 post_repeats[s + repeat.second - 1] = curr_repeat;
445 for (
unsigned post_repeat : post_repeats )
453 for (
unsigned i = 0;
i < aux.treeSize;
i++ )
459template <
class SymbolType >
static bool verbose
Verbose flag. Some algorithms print additional runtime information about internal datastructures or t...
Definition: GlobalData.h:24
static ext::reference_wrapper< ext::ostream > log
Standard loging stream. Mapped to descriptor 4.
Definition: GlobalData.h:78
Definition: ranked_symbol.hpp:20
Class extending the deque class from the standard library. Original reason is to allow printing of th...
Definition: deque.hpp:44
Class extending the list class from the standard library. Original reason is to allow printing of the...
Definition: list.hpp:44
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: map.hpp:185
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
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Tree structure represented as linear sequece as result of postorder traversal. The representation is ...
Definition: PostfixRankedTree.h:73
Definition: ExactSubtreeRepeats.h:29
static tree::PostfixRankedTree< unsigned > repeats(const tree::PostfixRankedTree< SymbolType > &tree)
Definition: ExactSubtreeRepeats.h:460
int i
Definition: AllEpsilonClosure.h:118
return res
Definition: MinimizeByPartitioning.h:145
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
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: BackwardOccurrenceTest.h:17