From d594d7981b151592a47912328b20f094e16011e5 Mon Sep 17 00:00:00 2001 From: Arthur Bols Date: Wed, 7 Mar 2018 02:40:30 +0100 Subject: [PATCH] created tuple class --- src/Tuple.java | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/Tuple.java diff --git a/src/Tuple.java b/src/Tuple.java new file mode 100644 index 0000000..16cb8f0 --- /dev/null +++ b/src/Tuple.java @@ -0,0 +1,34 @@ +public class Tuple2 { + + 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; + } + +}