summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2011-06-09 15:06:36 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-06-09 15:06:36 -0700
commitd54f3f41c4b41955b7b4382a08b97a356b31fde4 (patch)
treee7c6b29d7cdbd4833515be819912e42ad689b0a9 /graphics
parentfe93010446e68c747f4af727cbc48eaf63131689 (diff)
parent705d2ea63a4b3c2345af83eec9dabdeea29cfa9f (diff)
downloadframeworks_base-d54f3f41c4b41955b7b4382a08b97a356b31fde4.zip
frameworks_base-d54f3f41c4b41955b7b4382a08b97a356b31fde4.tar.gz
frameworks_base-d54f3f41c4b41955b7b4382a08b97a356b31fde4.tar.bz2
Merge "Override equals()/hashCode() for RS BaseObj."
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/renderscript/BaseObj.java30
1 files changed, 30 insertions, 0 deletions
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;
+ }
}