From 93164446611240b289577d4b9250d5c4a78fc85f Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Fri, 21 Jun 2019 14:56:07 +0200 Subject: [PATCH] move nontemplated code to cpp --- .../tree/properties/ExactSubtreeRepeats.cpp | 44 +++++++++++++++++++ .../src/tree/properties/ExactSubtreeRepeats.h | 40 ----------------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/alib2algo/src/tree/properties/ExactSubtreeRepeats.cpp b/alib2algo/src/tree/properties/ExactSubtreeRepeats.cpp index 37503771ab..99a4eef427 100644 --- a/alib2algo/src/tree/properties/ExactSubtreeRepeats.cpp +++ b/alib2algo/src/tree/properties/ExactSubtreeRepeats.cpp @@ -8,6 +8,50 @@ #include "ExactSubtreeRepeats.h" #include <registration/AlgoRegistration.hpp> +namespace tree::properties { + +void ExactSubtreeRepeats::assignLevel ( ext::deque < unsigned > S, unsigned l, ExactSubtreeRepeats::ExactSubtreeRepeatsAux & aux ) { + + std::queue < unsigned > Q4; + ext::vector < ext::deque < unsigned > > An ( aux.treeSize ); + ext::vector < bool > Bn ( aux.treeSize ); + + while ( !S.empty ( ) ) { + unsigned i = S.front ( ); + S.pop_front ( ); + unsigned root = i + l - 1; + + if ( root < aux.treeSize - 1 ) + if ( aux.FC [ root ] ) { + unsigned k = aux.H[aux.P[root]]; + An[k].push_back ( i ); + + if ( ! Bn [ k ] ) { + Bn[k] = true; + Q4.push ( k ); + } + } + + } + + while ( !Q4.empty ( ) ) { + unsigned k = Q4.front ( ); + Q4.pop ( ); + aux.LA[k].push ( ext::make_pair ( An[k], l ) ); + + /* This is line 15 (in paper) in the Assign-Level algorithm + * It has no effect here, as I made "An" local and the function ends right after the while loop. + * I leave it here to be consistent with the algorithm. + */ + /* Bn[k] = false; + * while ( !An[k].empty ( ) ) + * An[k].pop_front ( ); + */ + } +} + +} + namespace { auto ExactRepeatsPostfixRankedTree = registration::AbstractRegister < tree::properties::ExactSubtreeRepeats, tree::PostfixRankedTree < unsigned, DefaultRankType >, const tree::PostfixRankedTree < > & > ( tree::properties::ExactSubtreeRepeats::repeats ); diff --git a/alib2algo/src/tree/properties/ExactSubtreeRepeats.h b/alib2algo/src/tree/properties/ExactSubtreeRepeats.h index 99a5a5c58a..798376ecc0 100644 --- a/alib2algo/src/tree/properties/ExactSubtreeRepeats.h +++ b/alib2algo/src/tree/properties/ExactSubtreeRepeats.h @@ -272,46 +272,6 @@ void ExactSubtreeRepeats::ExactSubtreeRepeatsAux::buildFC ( const ext::vector < } } -void ExactSubtreeRepeats::assignLevel ( ext::deque < unsigned > S, unsigned l, ExactSubtreeRepeats::ExactSubtreeRepeatsAux & aux ) { - - std::queue < unsigned > Q4; - ext::vector < ext::deque < unsigned > > An ( aux.treeSize ); - ext::vector < bool > Bn ( aux.treeSize ); - - while ( !S.empty ( ) ) { - unsigned i = S.front ( ); - S.pop_front ( ); - unsigned root = i + l - 1; - - if ( root < aux.treeSize - 1 ) - if ( aux.FC [ root ] ) { - unsigned k = aux.H[aux.P[root]]; - An[k].push_back ( i ); - - if ( ! Bn [ k ] ) { - Bn[k] = true; - Q4.push ( k ); - } - } - - } - - while ( !Q4.empty ( ) ) { - unsigned k = Q4.front ( ); - Q4.pop ( ); - aux.LA[k].push ( ext::make_pair ( An[k], l ) ); - - /* This is line 15 (in paper) in the Assign-Level algorithm - * It has no effect here, as I made "An" local and the function ends right after the while loop. - * I leave it here to be consistent with the algorithm. - */ - /* Bn[k] = false; - * while ( !An[k].empty ( ) ) - * An[k].pop_front ( ); - */ - } -} - template < class SymbolType, class RankType > void ExactSubtreeRepeats::partition ( ext::deque < unsigned > S, unsigned l, int ac, const ext::vector < common::ranked_symbol < SymbolType, RankType > > & symbols, ExactSubtreeRepeats::ExactSubtreeRepeatsAux & aux ) { -- GitLab