-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathIndexedDoublePair.java
executable file
·53 lines (42 loc) · 1.32 KB
/
IndexedDoublePair.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
49
50
51
52
53
package spliterators.part2.exercise;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
public class IndexedDoublePair {
private final long index;
private final double value;
public IndexedDoublePair(long index, double value) {
this.index = index;
this.value = value;
}
public long getIndex() {
return index;
}
public double getValue() {
return value;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("index", index)
.append("value", value)
.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IndexedDoublePair that = (IndexedDoublePair) o;
return new EqualsBuilder()
.append(index, that.index)
.append(value, that.value)
.isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(index)
.append(value)
.toHashCode();
}
}