From 705d2ea63a4b3c2345af83eec9dabdeea29cfa9f Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Thu, 9 Jun 2011 10:11:54 -0700 Subject: Override equals()/hashCode() for RS BaseObj. This will be used by slang reflection to type-check parameters to functions that are of Allocation types (such as what happens with forEach). BUG=4203264 Change-Id: I2ba94531bbf53becf7695b253e1faa3dff099894 --- graphics/java/android/renderscript/BaseObj.java | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'graphics/java/android/renderscript/BaseObj.java') diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java index a17e735..63e7dd1 100644 --- a/graphics/java/android/renderscript/BaseObj.java +++ b/graphics/java/android/renderscript/BaseObj.java @@ -134,5 +134,35 @@ public class BaseObj { mName = mRS.nGetName(getID()); } + /** + * Calculates the hash code value for a BaseObj. + * + * @return int + */ + @Override + public int hashCode() { + return mID; + } + + /** + * Compare the current BaseObj with another BaseObj for equality. + * + * @param obj The object to check equality with. + * + * @return boolean + */ + @Override + public boolean equals(Object obj) { + // Early-out check to see if both BaseObjs are actually the same + if (this == obj) + return true; + + if (getClass() != obj.getClass()) { + return false; + } + + BaseObj b = (BaseObj) obj; + return mID == b.mID; + } } -- cgit v1.1