-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSymbol.java
More file actions
37 lines (28 loc) · 1023 Bytes
/
Symbol.java
File metadata and controls
37 lines (28 loc) · 1023 Bytes
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
public class Symbol implements Comparable<Symbol>{
String letter;//Inner node's letter is null.
int frequency;
double low;
double high;
double probability;
Symbol(String letter, int frequency){
this.letter = letter;
this.frequency = frequency;
}
Symbol(String letter, double p, double low, double high){
this.letter = letter;
this.probability = p;
this.low = low;
this.high = high;
}
@Override
/**
* It's a method of interface Comparable. We can use method Collections.sort(List<T>) then.
*/
public int compareTo(Symbol arg0) {
// TODO Auto-generated method stub
return letter.charAt(0) - arg0.letter.charAt(0);
}
public String toString(){
return letter + " " + String.valueOf(frequency);
}
}