-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDFAstate.h
83 lines (64 loc) · 2.19 KB
/
DFAstate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef lev_avt_DFAstate_h
#define lev_avt_DFAstate_h
#include <set>
#include "pair.h"
#include "NFAstate.cpp"
using std::set;
//Declarations:
template <class T>
class DFAState{
set<NFAState<T>, NFAStateComparation<T> > value;
public:
DFAState();
DFAState(const NFAState<T>& inpNFAState);
DFAState(const set<NFAState<T>, NFAStateComparation<T> >& inpNFAStates);
void AddNFAState(const NFAState<T>& inpNFAState);
const set<NFAState<T>, NFAStateComparation<T> >& GetValue() const;
};
template <class T>
class DFAStateComparation{
public:
bool operator() (const DFAState<T>& lhs, const DFAState<T>& rhs) const;
};
template <class T>
bool operator<(const DFAState<T>& inpLeftDFAState, const DFAState<T>& inpRightDFAState);
//Definitions:
template <class T>
DFAState<T>::DFAState(){}
template <class T>
DFAState<T>::DFAState(const NFAState<T>& inpNFAState){
this->value.insert(inpNFAState);
}
template <class T>
DFAState<T>::DFAState(const set<NFAState<T>, NFAStateComparation<T> >& inpNFAStates){
this->value = inpNFAStates;
}
template <class T>
void DFAState<T>::AddNFAState(const NFAState<T>& inpNFAState){
this->value.insert(inpNFAState);
}
template <class T>
const set<NFAState<T>, NFAStateComparation<T> >& DFAState<T>::GetValue() const{
return this->value;
}
template <class T>
bool DFAStateComparation<T>::operator()(const DFAState<T>& lhs, const DFAState<T>& rhs) const{
return lhs<rhs;
}
template <class T>
bool operator<(const DFAState<T>& inpLeftDFAState, const DFAState<T>& inpRightDFAState){
typename set<NFAState<T>, NFAStateComparation<T> >::reverse_iterator iterLeft = inpLeftDFAState.GetValue().rbegin();
typename set<NFAState<T>, NFAStateComparation<T> >::reverse_iterator iterRight = inpRightDFAState.GetValue().rbegin();
while (iterLeft != inpLeftDFAState.GetValue().rend() && iterRight != inpRightDFAState.GetValue().rend())
if (*iterLeft < *iterRight)
return true;
else if (*iterRight < *iterLeft)
return false;
else{
++iterLeft;
++iterRight;
continue;
}
return inpLeftDFAState.GetValue().size() < inpRightDFAState.GetValue().size();
}
#endif