Last active
September 20, 2016 14:58
-
-
Save tedigc/dc324d70d49729234010db0ed95fccc8 to your computer and use it in GitHub Desktop.
ImmutablePair stolen from GitHub, stored here for convenience.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Pair<L,R> { | |
| private final L left; | |
| private final R right; | |
| public Pair(L left, R right) { | |
| this.left = left; | |
| this.right = right; | |
| } | |
| public L getLeft() { | |
| return left; | |
| } | |
| public R getRight() { | |
| return right; | |
| } | |
| @Override | |
| public int hashCode() { | |
| return left.hashCode() ^ right.hashCode(); | |
| } | |
| @Override | |
| public boolean equals(Object o) { | |
| if (!(o instanceof Pair)) return false; | |
| Pair pairo = (Pair) o; | |
| return this.left.equals(pairo.getLeft()) && | |
| this.right.equals(pairo.getRight()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment