Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
NFACommon.cpp 851 B
/*
 * NFACommon.cpp
 *
 *  Created on: 16. 1. 2014
 *	  Author: Jan Vesely
 */

#include "NFACommon.h"
#include "label/LabelSetLabel.h"

#include <deque>
#include <algorithm>

namespace automaton {

namespace determinize {

automaton::State createDFAState(const std::set<automaton::State>& nfaStates) {
	std::set<label::Label> labelSet;
	for(const automaton::State& state : nfaStates) {
		labelSet.insert(state.getName());
	}
	return automaton::State(label::Label(label::LabelSetLabel(labelSet)));
}

std::set<automaton::State> recreateNFAStates(const automaton::State& dfaState) {
	std::set<automaton::State> states;
	for (const auto& label : static_cast<const label::LabelSetLabel&>(dfaState.getName().getData()).getData()) {
		states.insert(automaton::State(label));
	}
	return states;
}

} /* namespace determinize */

} /* namespace automaton */