Jdk1.6 container (13) of the annotation series for jdk-Java set and data structure in summary, jdkjdk1.6

Source: Internet
Author: User

Jdk1.6 container (13) of the annotation series for jdk-Java set and data structure in summary, jdkjdk1.6
Yes, this blogs is a summary article. At the beginning, I mentioned that learning java containers or collections can also be seen as learning and applying data structures. We have analyzed a lot of java containers and many common data structures. Today we will summarize these contents. Next, we will summarize the features of common data structures used at the underlying layer during the implementation of Java collections.1. Array)Structure Description: In program design, several variables of the same type are organized in an orderly manner to facilitate processing. The collections of these sort-by-order data elements are called arrays. Structural Features: Random Access, low insertion and deletion efficiency, and fixed memory. Java Collection: ArrayList, Vector source code parsing: Write annotation series to jdk jdk1.6 container (1)-ArrayList source code parsing to jdk write annotation series jdk1.6 container (10) -Stack & Vector source code parsing2. Linked List)Structure Description: it is a non-continuous and non-sequential storage structure of physical storage units. The logical sequence of data elements is achieved through the pointer links in the linked list. Structure Features: High insertion and deletion efficiency and low query efficiency. Java Collection: collections list, LinkedHashMap (linked list + hash table), LinkedHashSet (linked list + hash table) source code parsing: Write the annotation series to jdk jdk1.6 container (2) -parse the mongolist source code to write the annotation series to jdk. The jdk1.6 container (5)-mongohashmap source code parsing3. Hash table)Structure Description: If a record with the same keyword as K exists in the structure, it must be stored at the location of f (K. Therefore, you can directly obtain the queried records without comparing them. The corresponding relationship f is called a Hash function, and the table created based on this idea is a Hash function. Structure Features: High query efficiency, fast insertion and deletion, fixed memory, and hash conflicts. Java Collection: HashMap, HashSet, HashTable, LinkedHashMap (linked list + hash table), and LinkedHashSet (linked list + hash table) source code parsing: Write annotation series to jdk jdk1.6 container (4) -HashMap source code parsing: jdk-writing annotation series jdk1.6 container (6)-HashSet source code parsing & Map iterator-jdk-writing annotation series jdk1.6 container (5)-LinkedHashMap source code parsing4. Heap)Structure Description: in computer science, heap is a special tree data structure with each node having a value. Generally, the data structure of a heap refers to a binary heap. Heap is characterized by the smallest (or largest) value of the root node, and the two subtree of the root node is also a heap. Structural Features: Fast insertion and deletion, fast access to the primary and minimum items, and slow access to other items. Java set: PriorityQueue (priority queue implemented by the binary heap) source code parsing: Write the annotation series to jdk: jdk1.6 container (12)-PriorityQueue source code parsing5. Stack)Structure Description: Special linear tables can only be inserted and deleted at one end. It stores data according to the principle of "back-in-first-out". The first data is pushed to the bottom of the stack, and the last data is on the top of the stack. Data pops up from the top of the stack when data needs to be read. Structural Features: First In Last Out ). Java Collection: Stack source code parsing: write comments to jdk series jdk1.6 container (10)-Stack & Vector source code parsing  6. Queue)Structure Description: A special linear table that can be deleted only at the front end of the table and inserted at the back end of the table (rear. Structural Features: First In First Out ). Java set: ArrayDeque (dual-end Queue), pull list (dual-end Queue) source code parsing: Write annotation series to jdk jdk1.6 container (11) -Queue ArrayDeque source code parsing: Writing annotation series to jdk: jdk1.6 container (2)-javaslist source code parsing
7. Tree)Structure Description: it consists of n (n> = 1) finite nodes to form a set of hierarchies. (1) Each element is called a node ). (2) A specific node is called a root node or a root node ). (3) other data elements except the root node are divided into m (m ≥ 0) sets that do not conflict with each other T1, T2 ,...... Tm-1, where each collection of Ti (1 <= I <= m) itself is also a tree, called the original tree (subtree ). Structure Features: queries, inserts, and deletes are relatively fast, but the algorithm is complex. Java Collection: TreeMap (red and black tree), TreeSet (red and black tree) source code parsing: Write annotation series to jdk jdk1.6 container (7) -parse the TreeMap source code to write the annotation series jdk 1.6 container (8)-TreeSet & NavigableMap & NavigableSet source code 
We have summarized the relationship between common data structures and Java sets (of course, there is also a "figure" in common data structures, which is not described here ), the concepts and features of each data structure are briefly introduced. After learning about these conceptual theories, we can provide some guidance on how to use Java collections. Since then, we will not blindly use new ArrayList () and new HashMap, before use, we will try our best to think about the purpose of using the set. During the use process, we will insert and delete many, query more, and sort the set. In addition, a secret will be discovered through the summary. Of course, you may have discovered it long ago, that is, all data structures can be implemented using arrays and linked lists, the corresponding ArrayList and revoke list can also be used as the basis of any data structure. Learning theory is not an aim, and summarizing concepts is not a goal. Our slogan is no cavities! Amount ~ I learned how to use it, and used theory to guide practice. On paper, I had to know that it was a great task to learn and learn it ......

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.