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
for (const auto & transition : nfta.getTransitions()) {
if (transition.first.first != symbol) continue;
 
int i = (int) symbol.getRank().getData() - 1; //TODO az budou testy predelat na unsigned
for (; i >= 0; i--)
if (!recreateNFAStates(states[i]).count(transition.first.second[i])) break;
unsigned i = symbol.getRank().getData();
for (; i > 0; i--)
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;
}
......@@ -52,7 +52,7 @@ DFTA Determinize::determinize(const NFTA & nfta) {
std::set<State> nftaStates = recreateNFAStates(currentState);
 
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()) {
transitions.push_back(transition);
stops.push_back(0);
......@@ -60,12 +60,12 @@ DFTA Determinize::determinize(const NFTA & nfta) {
 
while(!transitions.empty()) {
auto transition = transitions.front();
int stop = stops.front();
unsigned stop = stops.front();
transitions.pop_front();
stops.pop_front();
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;
State nftaState = *recreateNFAStates(states[i]).begin();
if (nftaStates.count(nftaState)) {
......@@ -76,7 +76,7 @@ DFTA Determinize::determinize(const NFTA & nfta) {
if (!newNextStates.empty()) {
State newNextState = createDFAState(newNextStates);
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));
stops.push_back(i + 1);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment