File size: 1,705 Bytes
6f3ebfa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
package org.maltparser.ml.lib;


public class MaltFeatureNode implements Comparable<MaltFeatureNode> {
	int index;
	double value;
	
	public MaltFeatureNode() {
		index = -1;
		value = 0;
	}
	
	public MaltFeatureNode(int index, double value) {
		setIndex(index);
		setValue(value);
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public double getValue() {
		return value;
	}

	public void setValue(double value) {
		this.value = value;
	}

	public void clear() {
		index = -1;
		value = 0;
	}
	
	public int hashCode() {
		final int prime = 31;
		final long temp = Double.doubleToLongBits(value);
		return prime * (prime  + index) + (int) (temp ^ (temp >>> 32));
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MaltFeatureNode other = (MaltFeatureNode) obj;
		if (index != other.index)
			return false;
		if (Double.doubleToLongBits(value) != Double.doubleToLongBits(other.value))
			return false;
		return true;
	}
	
	public int compareTo(MaltFeatureNode aThat) {
		final int BEFORE = -1;
		final int EQUAL = 0;
		final int AFTER = 1;

		if (this == aThat)
			return EQUAL;

		if (this.index < aThat.index)
			return BEFORE;
		if (this.index > aThat.index)
			return AFTER;

		if (this.value < aThat.value)
			return BEFORE;
		if (this.value > aThat.value)
			return AFTER;

		return EQUAL;
	}

	public String toString() {
		final StringBuilder sb = new StringBuilder();
		sb.append("MaltFeatureNode [index=");
		sb.append(index);
		sb.append(", value=");
		sb.append(value);
		sb.append("]");
		return sb.toString();
	}
}