From 6c1d55cda87cee557c364dc02322c8c11c02070e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Nov 2010 07:54:12 +0100 Subject: Adding 'containsSafe' .. allowing verification of hash code --- src/java/com/jogamp/common/util/ArrayHashSet.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/java/com/jogamp') diff --git a/src/java/com/jogamp/common/util/ArrayHashSet.java b/src/java/com/jogamp/common/util/ArrayHashSet.java index 1d938f2..0840cde 100644 --- a/src/java/com/jogamp/common/util/ArrayHashSet.java +++ b/src/java/com/jogamp/common/util/ArrayHashSet.java @@ -162,7 +162,7 @@ public class ArrayHashSet *
* This is an O(1) operation. * - * @return true if the given element is contained by this list, + * @return true if the given element is contained by this list using fast hash map, * otherwise false. */ public final boolean contains(Object element) { @@ -174,7 +174,7 @@ public class ArrayHashSet *
* This is an O(n) operation, over the given Collection size. * - * @return true if the given Collection is completly contained by this list, + * @return true if the given Collection is completly contained by this list using hash map, * otherwise false. */ public final boolean containsAll(Collection c) { @@ -396,4 +396,20 @@ public class ArrayHashSet return identity; } + /** + * Test for containment + *
+ * This is an O(n) operation, using equals operation over the list. + *
+ * You may utilize this method to verify your hash values,
+ * ie {@link #contains(java.lang.Object)} and {@link #containsSafe(java.lang.Object)} + * shall have the same result.
+ * + * @return true if the given element is contained by this list using slow equals operation, + * otherwise false. + */ + public final boolean containsSafe(Object element) { + return data.contains(element); + } + } -- cgit v1.2.3