zoukankan      html  css  js  c++  java
  • HashMap源码-Basic hash bin node

     /**
         * Basic hash bin node, used for most entries.  (See below for
         * TreeNode subclass, and in LinkedHashMap for its Entry subclass.)
         */
        static class Node<K,V> implements Map.Entry<K,V> {
            final int hash;
            final K key;
            V value;
            Node<K,V> next;
    
            Node(int hash, K key, V value, Node<K,V> next) {
                this.hash = hash;
                this.key = key;
                this.value = value;
                this.next = next;
            }
    
            public final K getKey()        { return key; }
            public final V getValue()      { return value; }
            public final String toString() { return key + "=" + value; }
    
            public final int hashCode() {
                return Objects.hashCode(key) ^ Objects.hashCode(value);
            }
    
            public final V setValue(V newValue) {
                V oldValue = value;
                value = newValue;
                return oldValue;
            }
    
            public final boolean equals(Object o) {
                if (o == this)
                    return true;
                if (o instanceof Map.Entry) {
                    Map.Entry<?,?> e = (Map.Entry<?,?>)o;
                    if (Objects.equals(key, e.getKey()) &&
                        Objects.equals(value, e.getValue()))
                        return true;
                }
                return false;
            }
        }
  • 相关阅读:
    UML_04_时序图
    UML_03_类图
    UML_02_概述
    UML_00_资源帖
    UML_01_画图工具
    SpringCloud_00_资源帖
    Idea_03_常用快捷键
    Idea_02_常用配置
    Idea_01_安装与激活
    Codeforces命令行工具
  • 原文地址:https://www.cnblogs.com/fantiantian/p/9337473.html
Copyright © 2011-2022 走看看