2006-11-22 17:38:46 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2002 - 2006 IBM Corporation.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* IBM Corporation - initial API and implementation
|
|
|
|
*******************************************************************************/
|
|
|
|
package com.ibm.wala.util.intset;
|
|
|
|
|
|
|
|
/**
|
2007-05-30 19:05:23 +00:00
|
|
|
* A pair of ints. Note that an IntPair has value semantics.
|
2006-11-22 17:38:46 +00:00
|
|
|
*/
|
|
|
|
public class IntPair {
|
|
|
|
final int x;
|
|
|
|
|
|
|
|
final int y;
|
|
|
|
|
|
|
|
public IntPair(int x, int y) {
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Returns the x.
|
|
|
|
*/
|
|
|
|
public int getX() {
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Returns the y.
|
|
|
|
*/
|
|
|
|
public int getY() {
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
2007-05-30 15:16:05 +00:00
|
|
|
@Override
|
2006-11-22 17:38:46 +00:00
|
|
|
public boolean equals(Object obj) {
|
2007-05-15 19:35:57 +00:00
|
|
|
if (obj == null) {
|
|
|
|
return false;
|
|
|
|
}
|
2006-11-22 17:38:46 +00:00
|
|
|
if (obj.getClass() == this.getClass()) {
|
|
|
|
IntPair p = (IntPair) obj;
|
|
|
|
return p.getX() == x && p.getY() == y;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-05-30 15:16:05 +00:00
|
|
|
@Override
|
2006-11-22 17:38:46 +00:00
|
|
|
public int hashCode() {
|
|
|
|
return 8377 * x + y;
|
|
|
|
}
|
|
|
|
|
2007-05-30 15:16:05 +00:00
|
|
|
@Override
|
2006-11-22 17:38:46 +00:00
|
|
|
public String toString() {
|
|
|
|
return "[" + x + "," + y + "]";
|
|
|
|
}
|
2007-02-28 14:09:23 +00:00
|
|
|
|
|
|
|
public static IntPair make(int x, int y) {
|
2007-05-30 19:05:23 +00:00
|
|
|
return new IntPair(x, y);
|
2007-02-28 14:09:23 +00:00
|
|
|
}
|
2006-11-22 17:38:46 +00:00
|
|
|
}
|