KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > toolkits > scalar > Pair


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2002 Ondrej Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package soot.toolkits.scalar;
21
22 /** Just a pair of arbitrary objects.
23  * @author Ondrej Lhotak
24  */

25 public class Pair
26 {
27     public Pair( Object JavaDoc o1, Object JavaDoc o2 ) { this.o1 = o1; this.o2 = o2; }
28     public int hashCode() {
29         return o1.hashCode() + o2.hashCode();
30     }
31     public boolean equals( Object JavaDoc other ) {
32         if( other instanceof Pair ) {
33             Pair p = (Pair) other;
34             return o1.equals( p.o1 ) && o2.equals( p.o2 );
35         } else return false;
36     }
37     public String JavaDoc toString() {
38         return "Pair "+o1+","+o2;
39     }
40     public Object JavaDoc getO1() { return o1; }
41     public Object JavaDoc getO2() { return o2; }
42
43     protected Object JavaDoc o1;
44     protected Object JavaDoc o2;
45 }
46
47
48
Popular Tags