Fixed mssc

This commit is contained in:
Thomas Ave 2016-05-06 15:38:43 +02:00
parent 0f6742f005
commit 95f8b4dac1
1 changed files with 13 additions and 10 deletions

View File

@ -99,6 +99,7 @@ namespace lxs {
std::set<State> states;
std::queue<State> statequeue;
statequeue.push(s);
states.insert(s);
while(!statequeue.empty()) {
auto state = statequeue.front();
statequeue.pop();
@ -276,19 +277,22 @@ namespace lxs {
return compress(d, reachable, dist);
}
namespace { // Utility functions for mssc
namespace { // Utility function for mssc
std::set<State> getNextState(std::set<State> oldstate, char symbol, const NFA& e) {
std::set<State> states;
for(auto &state: oldstate) {
auto a = e.delta.find(state)->second;
auto newStates = a.find(symbol);
if(newStates != a.end()) {
for(auto &newstate:newStates->second) {
auto eclosestates = e.eClose(newstate);
for(auto &eclosestate:eclosestates) {
states.insert(eclosestate);
}
auto a = e.delta.find(state);
if(a != e.delta.end()) {
auto newStates = a->second.find(symbol);
if(newStates != a->second.end()) {
for(auto &newstate:newStates->second) {
auto eclosestates = e.eClose(newstate);
for(auto &eclosestate:eclosestates) {
states.insert(eclosestate);
}
}
}
}
}
@ -300,7 +304,6 @@ namespace lxs {
DFA mssc(const NFA& e) {
std::map<std::set<State>,std::map<char,std::set<State> > > dfa;
std::map<char, std::set<State> > trans;
for (int c = 0; c < 256; c++) {
trans.insert(std::pair<char,std::set<State> >(c,{(unsigned long long) -1}));