Java Hash Calculate hashV(Object... a)

Here you can find the source of hashV(Object... a)

Description

Computes a hash code over var args.

License

Apache License

Declaration

public static int hashV(Object... a) 

Method Source Code

//package com.java2s;
/*//from w w w .  j ava  2  s  . c o m
// Licensed to Julian Hyde under one or more contributor license
// agreements. See the NOTICE file distributed with this work for
// additional information regarding copyright ownership.
//
// Julian Hyde licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/

public class Main {
    /**
     * Computes a hash code over var args.
     */
    public static int hashV(Object... a) {
        int h = 19690721;
        for (Object o : a) {
            h = hash(h, o);
        }
        return h;
    }

    /**
     * Combines two integers into a hash code.
     */
    public static int hash(int i, int j) {
        return (i << 4) ^ j;
    }

    /**
     * Computes a hash code from an existing hash code and an object (which may
     * be null).
     */
    public static int hash(int h, Object o) {
        int k = (o == null) ? 0 : o.hashCode();
        return ((h << 4) | h) ^ k;
    }
}

Related

  1. hashSetSize(final int nrOfElements)
  2. hashThem(Object one, Object two)
  3. hashToFloat(int x, int y, long seed)
  4. hashToLong(final byte[] hash)
  5. hashToName(long l)
  6. hashValueFor(final boolean b)
  7. toHash(Long number)
  8. toHash(Object obj)