介绍
该实现与HashMap不同的是它维护一个双向链表,可以使HashMap有序。与HashMap一样,该类不安全。
结构
和HashMap的结构非常相似,只不过LinkedHashMap是一个双向链表
LinkedHashMap
分为两种节点 Entry
和 TreeNode
节点
Entry
节点结构:
class Entry extends HashMap.Node {
Entry before, after;
Entry(int hash, K key, V value, Node next) {
super(hash, key, value, next);
}
}