JDK1.8 source code reading series II: javaslist, jdk1.8javaslist

Source: Internet
Author: User

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.

 

    

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.