JDK1.8 source code reading series II: javaslist, jdk1.8javaslist
This article mainly describes some of my personal understandings of the implementation of the consumer list during my reading of the consumer list source code. If there is anything wrong, please point out ~
First, let's take a look at the inheritance diagram of the listing list:
Because AbstractCollection and AbstractList have already introduced ArrayList before, I will first read the AbstractSequentialList class, and then read the AbstractList class to record what I think is worth noting.
1. Related to the AbstractSequentialList class
The AbstractSequentialList class implements some simple methods such as get, set, add, remove, and addAll. The internal implementation of the method is implemented through listIterator (Index), while the AbstractSequentialList class will
ListIterator (Index) is declared as an abstract method, so the listIterator (Index) method in the listing list is actually called.
Ii. Related to the sort list class
The two-way linked list class is implemented. The internal classes used by linked list nodes are as follows:
1 public class LinkedList<E> { 2 ...... 3 private static class Node<E> { 4 E item; 5 Node<E> next; 6 Node<E> prev; 7 8 Node(Node<E> prev, E element, Node<E> next) { 9 this.item = element;10 this.next = next;11 this.prev = prev;12 }13 }14 .....15 }
The other methods are basically Node-based linked list operations.