From 62ff8440ed05f56e26706d53cdd61f72b1f53c7e Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Mon, 23 Jul 2012 07:28:05 -0600 Subject: [PATCH] implement Arrays.equals and Arrays.hashCode --- classpath/java/util/Arrays.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/classpath/java/util/Arrays.java b/classpath/java/util/Arrays.java index dc607189d9..006d192c22 100644 --- a/classpath/java/util/Arrays.java +++ b/classpath/java/util/Arrays.java @@ -42,6 +42,27 @@ public class Arrays { } } + public static int hashCode(T[] array) { + int hc = 823347; + for(T t : array) { + hc += t.hashCode(); + hc *= 3; + } + return hc; + } + + public static boolean equals(T[] a, T[] b) { + if(a.length != b.length) { + return false; + } + for(int i = 0; i < a.length; i++) { + if(!a[i].equals(b[i])) { + return false; + } + } + return true; + } + public static List asList(final T ... array) { return new List() { public String toString() {