在LInkedHashSet中维护了一个hash表和双向链表,LinkedHashSet中有head和tail,分别指向链表的头和尾
每一个节点有before和after属性,这样可以形成双向链表
在添加一个元素时,先求hash值,再求索引,确定该元素在table表中的位置,然后将添加的元素加入到双向链表(如果该元素已经存在,则不添加)
tail.next = newElement
newElement.pre = tail
这样在遍历LinkedHashSet时也能确保插入顺序和遍历顺序一致
原文:https://www.cnblogs.com/mx-info/p/14742758.html