-
Notifications
You must be signed in to change notification settings - Fork 0
/
HuffmanNode.java
48 lines (41 loc) · 990 Bytes
/
HuffmanNode.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
/**
* Created by Sonia on 11/28/2017.
*/
public class HuffmanNode implements Comparable <HuffmanNode> {
int weight;
String value;
HuffmanNode leftChild;
HuffmanNode rightChild;
HuffmanNode(int weight, String value){
this.weight = weight;
this.value = value;
}
public void setLeftChild(HuffmanNode child){
this.leftChild=child;
}
public void setRightChild(HuffmanNode child){
this.rightChild=child;
}
public HuffmanNode getLeftChild() {
return leftChild;
}
public HuffmanNode getRightChild() {
return rightChild;
}
public int getWeight(){
return this.weight;
}
public String getValue() {
return value;
}
public int compareTo(HuffmanNode o) {
int ret = 0;
if (this.weight < o.getWeight()){
ret = -1;
}
else if(this.weight > o.getWeight()){
ret = 1;
}
return ret;
}
}