From 53ad5e331789f59695bcacb9fe01e18770a51058 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Mon, 19 Dec 2016 14:25:53 +0100
Subject: [PATCH] fix templating -- use template parameter

---
 .../transform/AutomataConcatenation.h         | 40 +++++++++---------
 .../AutomataConcatenationEpsilonTransition.h  | 42 +++++++++----------
 .../automaton/transform/AutomatonIteration.h  |  2 +-
 .../src/automaton/transform/Compaction.h      | 18 ++++----
 4 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/alib2algo/src/automaton/transform/AutomataConcatenation.h b/alib2algo/src/automaton/transform/AutomataConcatenation.h
index faf1924ee0..fd14a9419f 100644
--- a/alib2algo/src/automaton/transform/AutomataConcatenation.h
+++ b/alib2algo/src/automaton/transform/AutomataConcatenation.h
@@ -35,13 +35,13 @@ automaton::NFA < SymbolType, StateType > AutomataConcatenation::concatenation(co
 	static StateType firstDefault ( 1 );
 	static StateType secondDefault ( 2 );
 
-	label::Label q01q02(first.getInitialState(), second.getInitialState());
-	automaton::NFA < SymbolType, StateType > res(label::Label(firstDefault, first.getInitialState()));
+	StateType q01q02(first.getInitialState(), second.getInitialState());
+	automaton::NFA < SymbolType, StateType > res(StateType(firstDefault, first.getInitialState()));
 
 	for(const auto& q : first.getStates())
-		res.addState(label::Label(firstDefault, q));
+		res.addState(StateType(firstDefault, q));
 	for(const auto& q : second.getStates())
-		res.addState(label::Label(secondDefault, q));
+		res.addState(StateType(secondDefault, q));
 	res.addState(q01q02);
 
 	for(const auto& symbol : first.getInputAlphabet())
@@ -54,25 +54,25 @@ automaton::NFA < SymbolType, StateType > AutomataConcatenation::concatenation(co
 
 	for(const auto& t : first.getTransitions()) {
 		for(const auto& q : t.second) {
-			res.addTransition(label::Label(firstDefault, t.first.first), t.first.second, label::Label(firstDefault, q));
+			res.addTransition(StateType(firstDefault, t.first.first), t.first.second, StateType(firstDefault, q));
 
 			if(first.getFinalStates().count(q) > 0)
-				res.addTransition(label::Label(firstDefault, t.first.first), t.first.second, label::Label(secondDefault, second.getInitialState()));
+				res.addTransition(StateType(firstDefault, t.first.first), t.first.second, StateType(secondDefault, second.getInitialState()));
 		}
 	}
 	for(const auto& t : second.getTransitions())
 		for(const auto& q : t.second)
-			res.addTransition(label::Label(secondDefault, t.first.first), t.first.second, label::Label(secondDefault, q));
+			res.addTransition(StateType(secondDefault, t.first.first), t.first.second, StateType(secondDefault, q));
 
 	for(const auto& t : first.getTransitionsFromState(first.getInitialState()))
 		for(const auto& q : t.second)
-			res.addTransition(q01q02, t.first.second, label::Label(firstDefault, q));
+			res.addTransition(q01q02, t.first.second, StateType(firstDefault, q));
 	for(const auto& t : second.getTransitionsFromState(second.getInitialState()))
 		for(const auto& q : t.second)
-			res.addTransition(q01q02, t.first.second, label::Label(secondDefault, q));
+			res.addTransition(q01q02, t.first.second, StateType(secondDefault, q));
 
 	for(const auto& q : second.getFinalStates())
-		res.addFinalState(label::Label(secondDefault, q));
+		res.addFinalState(StateType(secondDefault, q));
 	if(first.getFinalStates().count(first.getInitialState()) > 0)
 		res.addFinalState(q01q02);
 
@@ -84,13 +84,13 @@ automaton::NFA < SymbolType, StateType > AutomataConcatenation::concatenation(co
 	static StateType firstDefault ( 1 );
 	static StateType secondDefault ( 2 );
 
-	label::Label q01q02(first.getInitialState(), second.getInitialState());
-	automaton::NFA < SymbolType, StateType > res(label::Label(firstDefault, first.getInitialState()));
+	StateType q01q02(first.getInitialState(), second.getInitialState());
+	automaton::NFA < SymbolType, StateType > res(StateType(firstDefault, first.getInitialState()));
 
 	for(const auto& q : first.getStates())
-		res.addState(label::Label(firstDefault, q));
+		res.addState(StateType(firstDefault, q));
 	for(const auto& q : second.getStates())
-		res.addState(label::Label(secondDefault, q));
+		res.addState(StateType(secondDefault, q));
 	res.addState(q01q02);
 
 	for(const auto& symbol : first.getInputAlphabet())
@@ -102,21 +102,21 @@ automaton::NFA < SymbolType, StateType > AutomataConcatenation::concatenation(co
 		res.setInitialState(q01q02);
 
 	for(const auto& t : first.getTransitions()) {
-		res.addTransition(label::Label(firstDefault, t.first.first), t.first.second, label::Label(firstDefault, t.second));
+		res.addTransition(StateType(firstDefault, t.first.first), t.first.second, StateType(firstDefault, t.second));
 
 		if(first.getFinalStates().count(t.second) > 0)
-			res.addTransition(label::Label(firstDefault, t.first.first), t.first.second, label::Label(secondDefault, second.getInitialState()));
+			res.addTransition(StateType(firstDefault, t.first.first), t.first.second, StateType(secondDefault, second.getInitialState()));
 	}
 	for(const auto& t : second.getTransitions())
-		res.addTransition(label::Label(secondDefault, t.first.first), t.first.second, label::Label(secondDefault, t.second));
+		res.addTransition(StateType(secondDefault, t.first.first), t.first.second, StateType(secondDefault, t.second));
 
 	for(const auto& t : first.getTransitionsFromState(first.getInitialState()))
-		res.addTransition(q01q02, t.first.second, label::Label(firstDefault, t.second));
+		res.addTransition(q01q02, t.first.second, StateType(firstDefault, t.second));
 	for(const auto& t : second.getTransitionsFromState(second.getInitialState()))
-		res.addTransition(q01q02, t.first.second, label::Label(secondDefault, t.second));
+		res.addTransition(q01q02, t.first.second, StateType(secondDefault, t.second));
 
 	for(const auto& q : second.getFinalStates())
-		res.addFinalState(label::Label(secondDefault, q));
+		res.addFinalState(StateType(secondDefault, q));
 	if(first.getFinalStates().count(first.getInitialState()) > 0)
 		res.addFinalState(q01q02);
 
diff --git a/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h b/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h
index fb56b4a46b..dd4bf16f4b 100644
--- a/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h
+++ b/alib2algo/src/automaton/transform/AutomataConcatenationEpsilonTransition.h
@@ -37,7 +37,7 @@ automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > AutomataConcatenati
 	static StateType firstDefault ( 1 );
 	static StateType secondDefault ( 2 );
 
-	automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > res(label::Label(firstDefault, first.getInitialState()));
+	automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > res(StateType(firstDefault, first.getInitialState()));
 
 	for(const auto& symbol : first.getInputAlphabet())
 		res.addInputSymbol(symbol);
@@ -45,21 +45,21 @@ automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > AutomataConcatenati
 		res.addInputSymbol(symbol);
 
 	for(const auto& q : first.getStates())
-		res.addState(label::Label(firstDefault, q));
+		res.addState(StateType(firstDefault, q));
 	for(const auto& q : second.getStates())
-		res.addState(label::Label(secondDefault, q));
+		res.addState(StateType(secondDefault, q));
 
 	for(const auto& q : second.getFinalStates())
-		res.addFinalState(label::Label(secondDefault, q));
+		res.addFinalState(StateType(secondDefault, q));
 
 	for(const auto& t : first.getTransitions())
-		res.addTransition(label::Label(firstDefault, t.first.first), t.first.second, label::Label(firstDefault, t.second));
+		res.addTransition(StateType(firstDefault, t.first.first), t.first.second, StateType(firstDefault, t.second));
 
 	for(const auto& t : second.getTransitions())
-		res.addTransition(label::Label(secondDefault, t.first.first), t.first.second, label::Label(secondDefault, t.second));
+		res.addTransition(StateType(secondDefault, t.first.first), t.first.second, StateType(secondDefault, t.second));
 
 	for(const auto& q : first.getFinalStates())
-		res.addTransition(label::Label(firstDefault, q), label::Label(secondDefault, second.getInitialState()));
+		res.addTransition(StateType(firstDefault, q), StateType(secondDefault, second.getInitialState()));
 
 	return res;
 }
@@ -69,7 +69,7 @@ automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > AutomataConcatenati
 	static StateType firstDefault ( 1 );
 	static StateType secondDefault ( 2 );
 
-	automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > res(label::Label(firstDefault, first.getInitialState()));
+	automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > res(StateType(firstDefault, first.getInitialState()));
 
 	for(const auto& symbol : first.getInputAlphabet())
 		res.addInputSymbol(symbol);
@@ -77,23 +77,23 @@ automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > AutomataConcatenati
 		res.addInputSymbol(symbol);
 
 	for(const auto& q : first.getStates())
-		res.addState(label::Label(firstDefault, q));
+		res.addState(StateType(firstDefault, q));
 	for(const auto& q : second.getStates())
-		res.addState(label::Label(secondDefault, q));
+		res.addState(StateType(secondDefault, q));
 
 	for(const auto& q : second.getFinalStates())
-		res.addFinalState(label::Label(secondDefault, q));
+		res.addFinalState(StateType(secondDefault, q));
 
 	for(const auto& t : first.getTransitions())
 		for(const auto& q : t.second)
-			res.addTransition(label::Label(firstDefault, t.first.first), t.first.second, label::Label(firstDefault, q));
+			res.addTransition(StateType(firstDefault, t.first.first), t.first.second, StateType(firstDefault, q));
 
 	for(const auto& t : second.getTransitions())
 		for(const auto& q : t.second)
-			res.addTransition(label::Label(secondDefault, t.first.first), t.first.second, label::Label(secondDefault, q));
+			res.addTransition(StateType(secondDefault, t.first.first), t.first.second, StateType(secondDefault, q));
 
 	for(const auto& q : first.getFinalStates())
-		res.addTransition(label::Label(firstDefault, q), label::Label(secondDefault, second.getInitialState()));
+		res.addTransition(StateType(firstDefault, q), StateType(secondDefault, second.getInitialState()));
 
 	return res;
 }
@@ -103,7 +103,7 @@ automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > AutomataConcatenati
 	static StateType firstDefault ( 1 );
 	static StateType secondDefault ( 2 );
 
-	automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > res(label::Label(firstDefault, first.getInitialState()));
+	automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > res(StateType(firstDefault, first.getInitialState()));
 
 	for(const auto& symbol : first.getInputAlphabet())
 		res.addInputSymbol(symbol);
@@ -111,23 +111,23 @@ automaton::EpsilonNFA < SymbolType, EpsilonType, StateType > AutomataConcatenati
 		res.addInputSymbol(symbol);
 
 	for(const auto& q : first.getStates())
-		res.addState(label::Label(firstDefault, q));
+		res.addState(StateType(firstDefault, q));
 	for(const auto& q : second.getStates())
-		res.addState(label::Label(secondDefault, q));
+		res.addState(StateType(secondDefault, q));
 
 	for(const auto& q : second.getFinalStates())
-		res.addFinalState(label::Label(secondDefault, q));
+		res.addFinalState(StateType(secondDefault, q));
 
 	for(const auto& t : first.getTransitions())
 		for(const auto& q : t.second)
-			res.addTransition(label::Label(firstDefault, t.first.first), t.first.second, label::Label(firstDefault, q));
+			res.addTransition(StateType(firstDefault, t.first.first), t.first.second, StateType(firstDefault, q));
 
 	for(const auto& t : second.getTransitions())
 		for(const auto& q : t.second)
-			res.addTransition(label::Label(secondDefault, t.first.first), t.first.second, label::Label(secondDefault, q));
+			res.addTransition(StateType(secondDefault, t.first.first), t.first.second, StateType(secondDefault, q));
 
 	for(const auto& q : first.getFinalStates())
-		res.addTransition(label::Label(firstDefault, q), label::Label(secondDefault, second.getInitialState()));
+		res.addTransition(StateType(firstDefault, q), StateType(secondDefault, second.getInitialState()));
 
 	return res;
 }
diff --git a/alib2algo/src/automaton/transform/AutomatonIteration.h b/alib2algo/src/automaton/transform/AutomatonIteration.h
index 813ad6aadb..b40e1f2299 100644
--- a/alib2algo/src/automaton/transform/AutomatonIteration.h
+++ b/alib2algo/src/automaton/transform/AutomatonIteration.h
@@ -63,7 +63,7 @@ automaton::NFA < SymbolType, StateType > AutomatonIteration::iteration(const aut
 	res.addFinalState(newInitialState);
 
 	for(const auto& t : automaton.getTransitionsFromState(automaton.getInitialState()))
-		for (const label::Label & toState : t.second )
+		for (const StateType & toState : t.second )
 			res.addTransition(newInitialState, t.first.second, toState);
 
 	return res;
diff --git a/alib2algo/src/automaton/transform/Compaction.h b/alib2algo/src/automaton/transform/Compaction.h
index b9543cc154..897e76f37d 100644
--- a/alib2algo/src/automaton/transform/Compaction.h
+++ b/alib2algo/src/automaton/transform/Compaction.h
@@ -52,9 +52,9 @@ automaton::CompactNFA < SymbolType, StateType > Compaction::convert(const automa
 	automaton::CompactNFA < SymbolType, StateType > res(automaton.getInitialState());
 	res.setInputAlphabet(automaton.getInputAlphabet());
 
-	std::set<label::Label> visited;
+	std::set<StateType> visited;
 
-	std::stack<std::tuple<label::Label, label::Label, alphabet::Symbol>> stack; // state x lastFork x symbol we used to go to that state
+	std::stack<std::tuple<StateType, StateType, SymbolType>> stack; // state x lastFork x symbol we used to go to that state
 	for(const auto& transition: automaton.getTransitionsFromState(automaton.getInitialState()))
 		stack.push(std::make_tuple(transition.second, automaton.getInitialState(), transition.first.second));
 
@@ -62,17 +62,17 @@ automaton::CompactNFA < SymbolType, StateType > Compaction::convert(const automa
 		res.addFinalState(automaton.getInitialState());
 
 	while(!stack.empty()) {
-		label::Label q = std::move(std::get<0>(stack.top()));
-		label::Label lastFork = std::move(std::get<1>(stack.top()));
-		alphabet::Symbol symbol = std::move(std::get<2>(stack.top()));
+		StateType q = std::move(std::get<0>(stack.top()));
+		StateType lastFork = std::move(std::get<1>(stack.top()));
+		SymbolType symbol = std::move(std::get<2>(stack.top()));
 		stack.pop();
 
-		std::vector < alphabet::Symbol > path { symbol };
+		std::vector < SymbolType > path { symbol };
 
-		std::map<std::pair<label::Label, alphabet::Symbol>, label::Label> transitions;
+		std::map<std::pair<StateType, SymbolType>, StateType> transitions;
 		// only 1 child and nonfinal
 		while((transitions = automaton.getTransitionsFromState(q)).size() == 1 && automaton.getFinalStates().count(q) == 0) {
-			const std::pair<std::pair<label::Label, alphabet::Symbol>, label::Label>& transition = * transitions.begin();
+			const std::pair<std::pair<StateType, SymbolType>, StateType>& transition = * transitions.begin();
 			path.push_back(transition.first.second);
 			q = transition.second;
 		}
@@ -85,7 +85,7 @@ automaton::CompactNFA < SymbolType, StateType > Compaction::convert(const automa
 
 		res.addTransition(lastFork, path, q);
 
-		for(const std::pair<const std::pair<label::Label, alphabet::Symbol>, label::Label>& transition : automaton.getTransitionsFromState(q))
+		for(const std::pair<const std::pair<StateType, SymbolType>, StateType>& transition : automaton.getTransitionsFromState(q))
 			if(visited.insert(transition.second).second)
 				stack.push(std::make_tuple(transition.second, q, transition.first.second));
 
-- 
GitLab