From 80e0fa5a8897ca565d37e6388668e1f74afe9cb9 Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 9 Jan 2015 18:25:25 +0200 Subject: [PATCH] Add hash array computation to Objects --- src/com/annimon/stream/Objects.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/com/annimon/stream/Objects.java b/src/com/annimon/stream/Objects.java index 5e1b97db..5c0af649 100644 --- a/src/com/annimon/stream/Objects.java +++ b/src/com/annimon/stream/Objects.java @@ -16,6 +16,15 @@ public static int hashCode(Object o) { return o != null ? o.hashCode() : 0; } + public static int hash(Object... values) { + if (values == null) return 0; + + int result = 1; + for (Object element : values) + result = 31 * result + hashCode(element); + return result; + } + public static String toString(Object o, String nullDefault) { return (o != null) ? o.toString() : nullDefault; }