Java Array Deep Hash Code deepHashCode(Object a[])

Here you can find the source of deepHashCode(Object a[])

Description

Copied from Arrays.deepHashCode.

License

LGPL

Declaration


private static int deepHashCode(Object a[]) 

Method Source Code

//package com.java2s;
// Metawidget (licensed under LGPL)

public class Main {
    /**//  ww  w. j a v  a 2s  . co  m
     * Copied from <code>Arrays.deepHashCode</code>. <code>Arrays.deepHashCode</code> not supported
     * by GWT 1.7.
     */

    private static int deepHashCode(Object a[]) {

        if (a == null) {
            return 0;
        }

        int result = 1;

        for (Object element : a) {
            int elementHash = 0;
            if (element instanceof Object[]) {
                elementHash = deepHashCode((Object[]) element);
            } else if (element != null) {
                elementHash = element.hashCode();
            }

            result = 31 * result + elementHash;
        }

        return result;
    }
}

Related

  1. deepHashCode(byte[] array)
  2. deepHashCode(final Iterable stream)
  3. deepHashCode(Object a[])