1 2 3 | public class LinkedHashMap<K,V> extends HashMap<K,V> implements Map<K,V> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /** * HashMap.Node subclass for normal LinkedHashMap entries. */ //LinkedHashMap.Entey 继承自 HashMap.Node, //而 HashMap.TreeNode 又继承了 LinkedHashMap.Entey static class Entry<K,V> extends HashMap.Node<K,V> { //在父类的基础上增加了before 和 after //父类中存在 next //双向链表的连接通过before 和 after,哈希表中所有的元素可看作一个双向链表 //桶内单向链表的连接通过 next Entry<K,V> before, after; //构造方法 Entry(int hash, K key, V value, Node<K,V> next) { //父类构造方法 super(hash, key, value, next); } } private static final long serialVersionUID = 3801124242820219131L; /** * The head (eldest) of the doubly linked list. */ //head成员为双向链表的头 transient LinkedHashMap.Entry<K,V> head; /** * The tail (youngest) of the doubly linked list. */ //tail成员为双向链表的尾 transient LinkedHashMap.Entry<K,V> tail; /** * The iteration ordering method for this linked hash map: <tt>true</tt> * for access-order, <tt>false</tt> for insertion-order. * * @serial */ //迭代顺序, true 使用最近被访问的顺序, false为插入顺序 //the order in which its entries were last accessed, from least-recently accessed to most-recently (access-order), well-suited to building LRU caches final boolean accessOrder; |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |