随笔分类 - 底层代码欣赏
摘要:1 public E poll() { 2 if (size == 0) 3 return null; 4 int s = --size; 5 modCount++; 6 E result = (E) queue[0];//0下标处的那个元素就是最小的那个 7 E x = (E) queue[s];
阅读全文
摘要:1 //offer(E e) 2 public boolean offer(E e) { 3 if (e == null)//不允许放入null元素 4 throw new NullPointerException(); 5 modCount++; 6 int i = size; 7 if (i >
阅读全文
摘要:// 在访问元素之后,将该元素放到双向链表的尾巴处void afterNodeAccess(Node<K,V> e) { // move node to last LinkedHashMap.Entry<K,V> last; if (accessOrder && (last = tail) != e
阅读全文

浙公网安备 33010602011771号