Skip to content
Snippets Groups Projects
Commit 5141e7e6 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

use natural unsigned type

parent a1fad30d
No related branches found
No related tags found
No related merge requests found
...@@ -20,11 +20,11 @@ std::set<State> getTransitionRightSide(const NFTA & nfta, const alphabet::Ranked ...@@ -20,11 +20,11 @@ std::set<State> getTransitionRightSide(const NFTA & nfta, const alphabet::Ranked
for (const auto & transition : nfta.getTransitions()) { for (const auto & transition : nfta.getTransitions()) {
if (transition.first.first != symbol) continue; if (transition.first.first != symbol) continue;
   
int i = (int) symbol.getRank().getData() - 1; //TODO az budou testy predelat na unsigned unsigned i = symbol.getRank().getData();
for (; i >= 0; i--) for (; i > 0; i--)
if (!recreateNFAStates(states[i]).count(transition.first.second[i])) break; if (!recreateNFAStates(states[i - 1]).count(transition.first.second[i - 1])) break;
   
if (i == -1) res.insert(transition.second.begin(), transition.second.end()); if (i == 0) res.insert(transition.second.begin(), transition.second.end());
} }
return res; return res;
} }
...@@ -52,7 +52,7 @@ DFTA Determinize::determinize(const NFTA & nfta) { ...@@ -52,7 +52,7 @@ DFTA Determinize::determinize(const NFTA & nfta) {
std::set<State> nftaStates = recreateNFAStates(currentState); std::set<State> nftaStates = recreateNFAStates(currentState);
   
std::deque<std::pair<std::pair<alphabet::RankedSymbol, std::vector<State> >, State> > transitions; std::deque<std::pair<std::pair<alphabet::RankedSymbol, std::vector<State> >, State> > transitions;
std::deque<int> stops; std::deque<unsigned> stops;
for (const auto & transition : res.getTransitions()) { for (const auto & transition : res.getTransitions()) {
transitions.push_back(transition); transitions.push_back(transition);
stops.push_back(0); stops.push_back(0);
...@@ -60,12 +60,12 @@ DFTA Determinize::determinize(const NFTA & nfta) { ...@@ -60,12 +60,12 @@ DFTA Determinize::determinize(const NFTA & nfta) {
   
while(!transitions.empty()) { while(!transitions.empty()) {
auto transition = transitions.front(); auto transition = transitions.front();
int stop = stops.front(); unsigned stop = stops.front();
transitions.pop_front(); transitions.pop_front();
stops.pop_front(); stops.pop_front();
const std::vector<State> & states = transition.first.second; const std::vector<State> & states = transition.first.second;
   
for (int i = stop; i < (int) states.size(); i++) { for (unsigned i = stop; i < states.size(); i++) {
if (recreateNFAStates(states[i]).size() != 1) continue; if (recreateNFAStates(states[i]).size() != 1) continue;
State nftaState = *recreateNFAStates(states[i]).begin(); State nftaState = *recreateNFAStates(states[i]).begin();
if (nftaStates.count(nftaState)) { if (nftaStates.count(nftaState)) {
...@@ -76,7 +76,7 @@ DFTA Determinize::determinize(const NFTA & nfta) { ...@@ -76,7 +76,7 @@ DFTA Determinize::determinize(const NFTA & nfta) {
if (!newNextStates.empty()) { if (!newNextStates.empty()) {
State newNextState = createDFAState(newNextStates); State newNextState = createDFAState(newNextStates);
if (res.addState(newNextState)) todo.push_back(newNextState); if (res.addState(newNextState)) todo.push_back(newNextState);
if (res.addTransition(transition.first.first, newStates, newNextState) && i != (int) states.size()-1) { if (res.addTransition(transition.first.first, newStates, newNextState) && i + 1!= states.size()) {
transitions.push_back(std::make_pair(std::make_pair(transition.first.first, newStates), newNextState)); transitions.push_back(std::make_pair(std::make_pair(transition.first.first, newStates), newNextState));
stops.push_back(i + 1); stops.push_back(i + 1);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment