source: anac2020/BlingBling/src/main/java/geniusweb/blingbling/Ranknet/Pair.java@ 34

Last change on this file since 34 was 1, checked in by wouter, 4 years ago

#1910 added anac2020 parties

File size: 743 bytes
Line 
1package geniusweb.blingbling.Ranknet;
2
3import java.util.Objects;
4
5public class Pair<A, B> {
6
7 public final A fst;
8 public final B snd;
9
10 public Pair(A fst, B snd) {
11 this.fst = fst;
12 this.snd = snd;
13 }
14
15 public String toString() {
16 return "Pair[" + fst + "," + snd + "]";
17 }
18
19 public boolean equals(Object other) {
20 return
21 other instanceof Pair<?,?> &&
22 Objects.equals(fst, ((Pair<?,?>)other).fst) &&
23 Objects.equals(snd, ((Pair<?,?>)other).snd);
24 }
25
26 public int hashCode() {
27 if (fst == null) return (snd == null) ? 0 : snd.hashCode() + 1;
28 else if (snd == null) return fst.hashCode() + 2;
29 else return fst.hashCode() * 17 + snd.hashCode();
30 }
31
32 public static <A,B> Pair<A,B> of(A a, B b) {
33 return new Pair<>(a,b);
34 }
35}
Note: See TracBrowser for help on using the repository browser.