一.java.util.HashSet 1.1 HashSet集成结构 1.2 java.util.HashSet属性 private transient HashMap<E,Object> map; // Dummy value to associate with an Object in the backing Map private static final Object PRESENT = new Object(); HashSet的本质其实就是一个HashMap.Set集合一个重要的
一.java.util.HashSet 1.1 HashSet集成结构 1.2 java.util.HashSet属性 private transient HashMap<E,Object> map; // Dummy value to associate with an Object in the backing Map private static final Object PRESENT = new Object(); HashSet的本质其实就是一个HashMap.Set集合一个重要的
在java jdk8中对HashMap的源码进行了优化,在jdk7中,HashMap处理“碰撞”的时候,都是采用链表来存储,当碰撞的结点很多时,查询时间是O(n). 在jdk8中,HashMap处理“碰撞”增加了红黑树这种数据结构,当碰撞结点较少时,采用链表存储,当较大时,采用红黑树(特点是查询时间是O(logn))存储(有一个阀值控制,大于阀值,将链表存储转换成红黑树存储) HashMap的样子就变成下图的样子: 下面对源码进行分析: public class HashMap<K,V> ex
Dictionary是一个抽象类,Hashtable是它的一个子类. 类的声明:/** The <code>Dictionary</code> class is the abstract parent of any * class, such as <code>Hashtable</code>, which maps keys to values. * Every key and every value is an object. In any one &l
/** * An object that maps keys to values. A map cannot contain duplicate keys; * each key can map to at most one value. * * <p>This interface takes the place of the <tt>Dictionary</tt> class, which * was a totally abstract class rather t
自己实现了一个简单的LinkedList /** * Create by andy on 2018-07-03 11:44 * 根据 {@link java.util.LinkedList}源码 写了一个简单的实现,方便理解设计流程 * 该类是线程不安全的 */ public class FrameLinkedList<E> { private Node<E> first; private Node<E> last; private int size; public i