-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.java
125 lines (105 loc) · 2.2 KB
/
Node.java
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package Automata_DFA;
import java.util.HashSet;
import java.util.Set;
public class Node {
private String symbol;
private Node parent;
private Node left;
private Node right;
private Set<Integer> firstPos;
private Set<Integer> lastPos;
private boolean nullable;
public Node(String symbol) {
this.symbol = symbol;
parent = null;
left = null;
right = null;
firstPos = new HashSet<>();
lastPos = new HashSet<>();
nullable = false;
}
/**
* @return the symbol
*/
public String getSymbol() {
return symbol;
}
/**
* @param symbol the symbol to set
*/
public void setSymbol(String symbol) {
this.symbol = symbol;
}
/**
* @return the parent
*/
public Node getParent() {
return parent;
}
/**
* @param parent the parent to set
*/
public void setParent(Node parent) {
this.parent = parent;
}
/**
* @return the left
*/
public Node getLeft() {
return left;
}
/**
* @param left the left to set
*/
public void setLeft(Node left) {
this.left = left;
}
/**
* @return the right
*/
public Node getRight() {
return right;
}
/**
* @param right the right to set
*/
public void setRight(Node right) {
this.right = right;
}
public void addToFirstPos(int number) {
firstPos.add(number);
}
public void addAllToFirstPos(Set set) {
firstPos.addAll(set);
}
public void addToLastPos(int number) {
lastPos.add(number);
}
public void addAllToLastPos(Set set) {
lastPos.addAll(set);
}
/**
* @return the firstPos
*/
public Set<Integer> getFirstPos() {
return firstPos;
}
/**
* @return the lastPos
*/
public Set<Integer> getLastPos() {
return lastPos;
}
/**
* @return the nullable
*/
public boolean isNullable() {
return nullable;
}
/**
* @param nullable the nullable to set
*/
public void setNullable(boolean nullable) {
this.nullable = nullable;
}
}