集册 Java实例教程 映射的深层哈希代码

映射的深层哈希代码

欢马劈雪     最近更新时间:2020-01-02 10:19:05

479
映射的深层哈希代码

/**

 * (c) 2009-2014 Peter Wullinger

 *

 * $Id$

 *

 * Use, modification and restribution of this file are covered by the

 * terms of the Artistic License 2.0.

 *

 * You should have received a copy of the license terms in a file named

 * "LICENSE" together with this software package.

 *

 * Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT

 * HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED

 * WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR

 * A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE

 * EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO

 * COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,

 * INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT

 * OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH

 * DAMAGE.

 **///n o w j a v a . c o m 提 供

//package com.nowjava;


import java.util.Map;


public class Main {

    public static <K, V> int deepHashCode(Map.Entry<K, V> entry) {

        return entry.getKey().hashCode() * entry.getValue().hashCode();

    }


    public static <K, V> int deepHashCode(Map<K, V> m) {

        int hashCode = 91;

        
展开阅读全文