Skip to content
Snippets Groups Projects
Commit fd350150 authored by Jan Vesely's avatar Jan Vesely
Browse files

build update set according to definition

parent 1be54fa9
No related branches found
No related tags found
No related merge requests found
......@@ -151,7 +151,7 @@ Automaton* RhdpdaDeterminizer2::determinize()
for (const auto& b : this->rhdpda->getInputAlphabet()) {
SComponent& s = unmarkedStateData->s;
 
set<PairOfPairs> update;
set<StatesPair> update;
for (const auto& pairOfPairs : s.pairsOfPairs) {
const State& r = pairOfPairs.pair1.state;
const Symbol& Z = pairOfPairs.pair1.symbol;
......@@ -164,9 +164,7 @@ Automaton* RhdpdaDeterminizer2::determinize()
if (pushTransition.getInput() == a && pushTransition.getTo() == r &&
popTransition.getInput() == b && popTransition.getFrom() == rPrimed &&
pushTransition.getPush().front() == Z && popTransition.getPop().front() == Z) {
StateSymbolPair pair1(p, Z);
StateSymbolPair pair2(q, Z);
update.insert(PairOfPairs(pair1, pair2));
update.insert(StatesPair(p, q));
}
}
}
......@@ -180,8 +178,8 @@ Automaton* RhdpdaDeterminizer2::determinize()
for (const auto& rPrimed : this->allRComponents) {
RComponent rDoublePrimed;
for (const auto& updateItem : update) {
const State& p = updateItem.pair1.state;
const State& q = updateItem.pair2.state;
const State& p = updateItem.state1;
const State& q = updateItem.state2;
for (const auto& rPrimedPair : rPrimed.pairs) {
if (rPrimedPair.state == p) {
const Symbol& Y = rPrimedPair.symbol;
......@@ -191,8 +189,8 @@ Automaton* RhdpdaDeterminizer2::determinize()
}
SComponent sDoublePrimed;
for (const auto& updateItem : update) {
const State& p = updateItem.pair1.state;
const State& q = updateItem.pair2.state;
const State& p = updateItem.state1;
const State& q = updateItem.state2;
for (const auto& sPrimedPair : sPrimed.pairsOfPairs) {
if (sPrimedPair.pair2.state == p) {
const StateSymbolPair& x = sPrimedPair.pair1;
......
......@@ -150,7 +150,7 @@ Automaton* RhdpdaDeterminizer3::determinize()
for (const auto& b : this->rhdpda->getInputAlphabet()) {
SComponent& s = unmarkedStateData->s;
 
set<PairOfPairs> update;
set<StatesPair> update;
for (const auto& pairOfPairs : s.pairsOfPairs) {
const State& r = pairOfPairs.pair1.state;
const Symbol& Z = pairOfPairs.pair1.symbol;
......@@ -163,9 +163,7 @@ Automaton* RhdpdaDeterminizer3::determinize()
if (pushTransition.getInput() == a && pushTransition.getTo() == r &&
popTransition.getInput() == b && popTransition.getFrom() == rPrimed &&
pushTransition.getPush().front() == Z && popTransition.getPop().front() == Z) {
StateSymbolPair pair1(p, Z);
StateSymbolPair pair2(q, Z);
update.insert(PairOfPairs(pair1, pair2));
update.insert(StatesPair(p, q));
}
}
}
......@@ -179,8 +177,8 @@ Automaton* RhdpdaDeterminizer3::determinize()
for (const auto& rPrimed : this->allRComponents) {
RComponent rDoublePrimed;
for (const auto& updateItem : update) {
const State& p = updateItem.pair1.state;
const State& q = updateItem.pair2.state;
const State& p = updateItem.state1;
const State& q = updateItem.state2;
for (const auto& rPrimedPair : rPrimed.pairs) {
if (rPrimedPair.state == p) {
const Symbol& Y = rPrimedPair.symbol;
......@@ -190,8 +188,8 @@ Automaton* RhdpdaDeterminizer3::determinize()
}
SComponent sDoublePrimed;
for (const auto& updateItem : update) {
const State& p = updateItem.pair1.state;
const State& q = updateItem.pair2.state;
const State& p = updateItem.state1;
const State& q = updateItem.state2;
for (const auto& sPrimedPair : sPrimed.pairsOfPairs) {
if (sPrimedPair.pair2.state == p) {
const StateSymbolPair& x = sPrimedPair.pair1;
......
......@@ -164,7 +164,7 @@ Automaton* RhdpdaDeterminizer4::determinize()
for (const auto& a : this->rhdpda->getInputAlphabet()) {
for (const auto& b : this->rhdpda->getInputAlphabet()) {
SComponent& s = unmarkedStateData->s;
set<PairOfPairs> update;
set<StatesPair> update;
for (const auto& pairOfPairs : s.pairsOfPairs) {
const State& r = pairOfPairs.pair1.state;
const Symbol& Z = pairOfPairs.pair1.symbol;
......@@ -177,9 +177,7 @@ Automaton* RhdpdaDeterminizer4::determinize()
if (pushTransition.getInput() == a && pushTransition.getTo() == r &&
popTransition.getInput() == b && popTransition.getFrom() == rPrimed &&
pushTransition.getPush().front() == Z && popTransition.getPop().front() == Z) {
StateSymbolPair pair1(p, Z);
StateSymbolPair pair2(q, Z);
update.insert(PairOfPairs(pair1, pair2));
update.insert(StatesPair(p, q));
}
}
}
......@@ -191,8 +189,8 @@ Automaton* RhdpdaDeterminizer4::determinize()
for (const auto& sPrimed : this->allSComponents) {
SComponent sDoublePrimed;
for (const auto& updateItem : update) {
const State& p = updateItem.pair1.state;
const State& q = updateItem.pair2.state;
const State& p = updateItem.state1;
const State& q = updateItem.state2;
for (const auto& sPrimedPair : sPrimed.pairsOfPairs) {
if (sPrimedPair.pair2.state == p) {
const StateSymbolPair& x = sPrimedPair.pair1;
......
......@@ -122,6 +122,35 @@ struct StateData
};
 
 
/**
* Struct fot storing pair of two states.
*/
struct StatesPair
{
State state1;
State state2;
StatesPair(const State& state1, const State& state2)
: state1(state1),
state2(state2) {}
bool operator < (const StatesPair& other) const
{
return (state1 < other.state1) || ((state1 == other.state1) && (state2 < other.state2));
}
bool operator == (const StatesPair& other) const
{
return (state1 == other.state1) && (state2 == other.state2);
}
bool operator != (const StatesPair& other) const
{
return (state1 != other.state1) || (state2 != other.state2);
}
};
}
}
#endif
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