Skip to content

Instantly share code, notes, and snippets.

@sc0rch
Last active July 9, 2016 01:46
Show Gist options
  • Select an option

  • Save sc0rch/7a57e0b2c5a45962de33d228d2e7bb1e to your computer and use it in GitHub Desktop.

Select an option

Save sc0rch/7a57e0b2c5a45962de33d228d2e7bb1e to your computer and use it in GitHub Desktop.

Revisions

  1. sc0rch revised this gist Jul 9, 2016. No changes.
  2. sc0rch created this gist Jul 8, 2016.
    26 changes: 26 additions & 0 deletions Tuple.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    /**
    * Created by sc0rch on 05.07.16.
    */
    public class Tuple<L,R> {
    private final L left;
    private final R right;

    public Tuple(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 Tuple)) return false;
    Tuple t = (Tuple) o;
    return this.left.equals(t.getLeft()) &&
    this.right.equals(t.getRight());
    }
    }