首页 > 其他 > 详细

LinkedHashMap

时间:2019-02-25 00:20:13      阅读:180      评论:0      收藏:0      [点我收藏+]

LinkedHashMap既是一个HashMap,也是一个链表

package java.util;

import java.util.function.Consumer;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.io.IOException;

public class LinkedHashMap<K,V>
    extends HashMap<K,V>
    implements Map<K,V> {
    
    static class Entry<K,V> extends HashMap.Node<K,V> {
        // LinkedHashMap的每个Entry元素多了两个引用
        Entry<K,V> before, after;
        Entry(int hash, K key, V value, Node<K,V> next) {
            super(hash, key, value, next);
        }
    }
    // 第一个元素
    transient LinkedHashMap.Entry<K,V> head;
    // 最后一个元素
    transient LinkedHashMap.Entry<K,V> tail;
}

// HashMap.Node
static class Node<K,V> implements Map.Entry<K,V> {
    final int hash;
    final K key;
    V value;
    Node<K,V> next;
}

 

LinkedHashMap

原文:https://www.cnblogs.com/Mike_Chang/p/10428764.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!