-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pair.java
62 lines (50 loc) · 946 Bytes
/
Pair.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
54
55
56
57
58
59
60
61
62
package pdf;
/*
* This class is defined to hold two paired generic types
*/
public class Pair<V, E> {
private V val;
private E ele;
public Pair(V val, E ele){
this.val = val;
this.ele = ele;
}
public V getValue(){
return this.val;
}
public E getElement(){
return this.ele;
}
public void setValue(V val){
this.val = val;
}
public void setElement(E ele){
this.ele = ele;
}
@Override
public int hashCode(){
return this.val.hashCode() ^ this.ele.hashCode();
}
@Override
public boolean equals(Object o){
if(o == null){
return false;
}
if(o == this){
return true;
}
if(!(o instanceof Pair<?,?>)){
return false;
}
Pair<V,E> other = (Pair<V,E>)o;
if(this.val.equals(other.val) && this.ele.equals(other.ele)){
return true;
}else{
return false;
}
}
@Override
public String toString(){
return "{" + this.val.toString() + ", " + this.ele.toString() + "}";
}
}