-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOurLong.java
43 lines (35 loc) · 893 Bytes
/
OurLong.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
import org.apache.hadoop.io.WritableComparable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class OurLong implements WritableComparable<OurLong> {
private Long num;
public OurLong(){}
public OurLong(Long n){
num = n;
}
@Override
public int compareTo(OurLong other) {
if (other.getNum() == num)
return 0;
else if (other.getNum() > num)
return 1;
else
return -1;
}
@Override
public void write(DataOutput dataOutput) throws IOException {
dataOutput.writeLong(num);
}
@Override
public void readFields(DataInput dataInput) throws IOException {
num= dataInput.readLong();
}
public Long getNum() {
return num;
}
@Override
public String toString() {
return num.toString();
}
}