Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Pair<T1 , T2> {
- T1 x;
- T2 y;
- Pair(T1 _x , T2 _y){
- x = _x;
- y = _y;
- }
- T1 first(){
- return x;
- }
- T2 second(){
- return y;
- }
- public boolean equals(Object other){
- if (other instanceof Pair) {
- Pair otherPair = (Pair) other;
- return
- (( this.x == otherPair.x ||
- ( this.x != null && otherPair.x != null &&
- this.x.equals(otherPair.x))) &&
- ( this.y == otherPair.y ||
- ( this.y != null && otherPair.y != null &&
- this.y.equals(otherPair.y))) );
- }
- return false;
- }
- public int hashCode(){
- int hash = 31;
- int res = 1;
- res = hash * res + x.hashCode();
- res = hash * res + y.hashCode();
- return res;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement