39 lines
958 B
C++
39 lines
958 B
C++
#pragma once
|
|
|
|
#include <map>
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
namespace NFA {
|
|
class NFATree {
|
|
public:
|
|
class Vertex {
|
|
public:
|
|
Vertex();
|
|
Vertex(bool is_finale, bool is_start);
|
|
|
|
bool IsFinal() const;
|
|
bool IsStart() const;
|
|
void SetFinal(bool value);
|
|
void SetStart(bool value);
|
|
|
|
std::map<char, std::vector<std::weak_ptr<Vertex>>> transitions;
|
|
private:
|
|
bool is_final_ = false;
|
|
bool is_start_ = false;
|
|
};
|
|
|
|
void RemoveVertex(std::shared_ptr<Vertex>);
|
|
void RemoveFinalVertex(std::shared_ptr<Vertex>);
|
|
void RemoveStartVertex(std::shared_ptr<Vertex>);
|
|
|
|
void Composition(NFATree&&, std::vector<std::shared_ptr<Vertex>>
|
|
start_vertexes, std::vector<std::shared_ptr<Vertex>>
|
|
final_vertexes);
|
|
private:
|
|
std::vector<std::shared_ptr<Vertex>> vertexes_;
|
|
std::vector<std::weak_ptr<Vertex>> final_vertexes_;
|
|
std::vector<std::weak_ptr<Vertex>> start_vertexes_;
|
|
};
|
|
}
|