Last active
March 12, 2016 11:27
-
-
Save cyclotimia/04269e7956adc9f98d55 to your computer and use it in GitHub Desktop.
Revisions
-
cyclotimia revised this gist
Mar 12, 2016 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,19 +2,23 @@ class Pair<T, M> { private final T first; private final M second; // конструктор private Pair(T value1, M value2) { this.first = value1; this.second = value2; } // получить первый эл-т пары public T getFirst() { return this.first; } // получить второй эл-т пары public M getSecond() { return this.second; } // equals @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -27,13 +31,15 @@ class Pair<T, M> { } // hashcode @Override public int hashCode() { int result = first != null ? first.hashCode() : 0; result = 31 * result + (second != null ? second.hashCode() : 0); return result; } // конструктор public static <T, M> Pair of(T value1, M value2) { return new Pair(value1, value2); } -
cyclotimia created this gist
Dec 21, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ class Pair<T, M> { private final T first; private final M second; private Pair(T value1, M value2) { this.first = value1; this.second = value2; } public T getFirst() { return this.first; } public M getSecond() { return this.second; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Pair<?, ?> pair = (Pair<?, ?>) obj; if (first != null ? !first.equals(pair.first) : pair.first != null) return false; return !(second != null ? !second.equals(pair.second) : pair.second != null); } @Override public int hashCode() { int result = first != null ? first.hashCode() : 0; result = 31 * result + (second != null ? second.hashCode() : 0); return result; } public static <T, M> Pair of(T value1, M value2) { return new Pair(value1, value2); } }