001 // GraphLab Project: http://graphlab.sharif.edu 002 // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology 003 // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ 004 005 package graphlab.platform.lang; 006 007 /** 008 * A pair of two objects 009 * @author Omid 010 */ 011 public class Pair<First, Second> { 012 public First first; 013 public Second second; 014 015 public Pair(First f, Second s) { 016 first = f; 017 second = s; 018 } 019 020 public boolean equals(Object obj) { 021 if (obj == null) 022 return false; 023 if (!(obj instanceof Pair)) 024 return false; 025 Pair t = (Pair) obj; 026 if (first == null || second == null) 027 return false; 028 return !(!first.equals(t.first) || !second.equals(t.second)); 029 } 030 031 public int hashCode() { 032 return first.hashCode() + 100000 * second.hashCode(); 033 } 034 035 public String toString() { 036 return first.toString() + ", " + second.toString(); 037 } 038 039 }