一步一步解析java集合框架HashMap源码(1)
2016-08-03 19:13
597 查看
首先看HashMap的底层结构实现:
static class Node<K,V> implements Map.Entry<K,V> { final int hash;//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; } }
相关文章推荐
- 一步一步解析java集合框架HashMap源码(3)
- 一步一步解析java集合框架HashMap源码(1)
- 一步一步解析java集合框架HashMap源码(2)
- Java集合框架之HashMap源码解析
- 一步一步解析java集合框架LinkedList源码(3)
- Java集合框架--HashMap源码解析(JDK1.7)
- Java集合框架之 Java HashMap 源码解析
- HashMap-Java集合框架之 Java HashMap 源码解析
- Java集合框架之三:HashMap源码解析
- HashMap源码及原理解析
- java集合框架中HashMap源码(基于JDK1.6)
- Java之HashMap源码解析1
- 【转】Java HashMap 源码解析(好文章)
- HashMap、HashTable、TreeMap 深入分析及源码解析
- HashMap源码解析
- 给jdk写注释系列之jdk1.6容器(4)-HashMap源码解析
- hashMap源码解析
- Java HashMap 源码解析
- Java HashMap 源码解析
- java集合框架之java HashMap代码解析