created tuple class
This commit is contained in:
34
src/Tuple.java
Normal file
34
src/Tuple.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
public class Tuple2<T1, T2> {
|
||||||
|
|
||||||
|
public final T1 item1;
|
||||||
|
public final T2 item2;
|
||||||
|
|
||||||
|
public Tuple2(T1 x, T2 y) {
|
||||||
|
this.item1 = x;
|
||||||
|
this.item2 = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (!(obj instanceof Tuple2))
|
||||||
|
return false;
|
||||||
|
final Tuple2<?, ?> other = (Tuple2<?, ?>) obj;
|
||||||
|
if (_1 == null) {
|
||||||
|
if (other._1 != null)
|
||||||
|
return false;
|
||||||
|
} else if (!_1.equals(other._1))
|
||||||
|
return false;
|
||||||
|
if (_2 == null) {
|
||||||
|
if (other._2 != null)
|
||||||
|
return false;
|
||||||
|
} else if (!_2.equals(other._2))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user