-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrieNode.java
More file actions
66 lines (57 loc) · 1.23 KB
/
TrieNode.java
File metadata and controls
66 lines (57 loc) · 1.23 KB
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
package com.trie;
import java.util.ArrayList;
import java.util.List;
public class TrieNode {
private char value;
private List<TrieNode> children;
private boolean isName;
private String finalName;
public TrieNode(char val) {
this.value=val;
this.children= new ArrayList<TrieNode>();
this.isName=false;
this.finalName=new String();
}
public List<TrieNode> getChildren(){
return children;
}
public char getValue() {
return value;
}
public boolean isName() {
return isName;
}
public void setIsName(boolean val) {
isName=val;
}
public void addChildren(TrieNode newNode) {
children.add(newNode);
}
public boolean childrenMatch(char item) {
for(TrieNode tn: children) {
if(tn.getValue()==item)
return true;
}
return false;
}
public TrieNode getChild(char item) {
for(TrieNode tn: children) {
if(tn.getValue()==item)
return tn;
}
return null;
}
public int getChildState(char item) {
for(TrieNode tn: children) {
if(tn.getValue()==item)
return 1;
}
return 0;
}
public String getFinalName() {
return finalName;
}
public void setFinalName(String finalName) {
this.finalName = finalName;
}
}