Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ObjectUtil.java')
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ObjectUtil.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ObjectUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ObjectUtil.java
index 01f8d39f77..2b8a6218f0 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ObjectUtil.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ObjectUtil.java
@@ -43,6 +43,23 @@ public final class ObjectUtil
return o.hashCode();
}
+ /**
+ * A collision-free hash code for small sets (<=4) of small, positive integers (<=128)
+ *
+ * @since 3.2
+ */
+ public static int hashCode(int... values)
+ {
+ int hash = 0;
+ for (int i = 0; i < values.length; i++)
+ {
+ hash += values[i];
+ hash = (hash << 7) - hash;
+ }
+
+ return hash;
+ }
+
public static int hashCode(long num)
{
return (int)(num >> 32) ^ (int)(num & 0xffffffff);

Back to the top