1 package de.bwaldvogel.liblinear;
2
3 public class FeatureNode {
4
5 public final int index;
6 public double value;
7
8 public FeatureNode( final int index, final double value ) {
9 if (index < 0) throw new IllegalArgumentException("index must be >= 0");
10 this.index = index;
11 this.value = value;
12 }
13
14 @Override
15 public int hashCode() {
16 final int prime = 31;
17 int result = 1;
18 result = prime * result + index;
19 long temp;
20 temp = Double.doubleToLongBits(value);
21 result = prime * result + (int)(temp ^ (temp >>> 32));
22 return result;
23 }
24
25 @Override
26 public boolean equals(Object obj) {
27 if (this == obj) return true;
28 if (obj == null) return false;
29 if (getClass() != obj.getClass()) return false;
30 FeatureNode other = (FeatureNode)obj;
31 if (index != other.index) return false;
32 if (Double.doubleToLongBits(value) != Double.doubleToLongBits(other.value)) return false;
33 return true;
34 }
35
36 @Override
37 public String toString() {
38 return "FeatureNode(idx=" + index + ", value=" + value + ")";
39 }
40 }