-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAbstractHierarchicalStatisticTree.java
More file actions
51 lines (40 loc) · 1.06 KB
/
AbstractHierarchicalStatisticTree.java
File metadata and controls
51 lines (40 loc) · 1.06 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
public abstract class AbstractHierarchicalStatisticTree<K> implements Comparable<K>, IHierarchicalStatisticTree<K> {
K key;
Integer count;
protected AbstractHierarchicalStatisticTree(){
this.count = 0;
}
@Override
public String toString(){
if(this.key==null)
return "[TOTAL:".concat(this.count.toString()) + "]";
else
return "[" + this.key.toString().concat(":").concat(this.count.toString()) + "]";
}
@SuppressWarnings("unchecked")
public int compareTo(final K o) {
return ((Comparable<K>)this.key).compareTo((K)o);
}
@SuppressWarnings("unchecked")
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj == null || obj.getClass() != this.getClass()) {
return false;
}
return this.key.equals(((AbstractHierarchicalStatisticTree<K>) obj).getKey());
}
public K getKey() {
return key;
}
public void setKey(K key) {
this.key = key;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
}