Write an annotation to the JDK series of jdk1.6 Containers (13)-Summary of the Java collection and data structure

Source: Internet
Author: User

Yes, this blogs is a summary, at the very beginning I mentioned that the Java container or collection of learning can also be seen as a data structure learning and application.      In the front we analyzed a lot of Java containers, but also touched a lot of common data structure, today we will summarize the content. Below we summarize in the dimension of the data structure, in the implementation process of the Java collection, what are the common data structures used in the bottom layer, and what characteristics they have respectively. 1. Arrays (array)Structure Description: In the program design, in order to deal with the convenience, the same type of a number of variables organized in an orderly form.     The collection of these ordered, homogeneous data elements is called an array.     Structure features: Can be randomly accessed, insert and delete inefficient, memory fixed. Java collection: ArrayList, Vector source code analysis: to the JDK write annotation series of jdk1.6 container (1)-arraylist source code to the JDK write Comment series jdk1.6 container (Ten)-stack&vector source resolution 2. Linked list (Linked list)Structure Description: Is a non-sequential, non-sequential storage structure on a physical storage unit, and the logical order of the data elements is implemented by the order of the pointers in the linked list.     Structural features: High efficiency in insertion and deletion, low search efficiency.                   Java collection: LinkedList, Linkedhashmap (linked list + hash table), Linkedhashset (linked list + hash table) Source parsing: Write a comment series to the JDK jdk1.6 container (2)-linkedlist source parsing Write notes for JDK Series jdk1.6 container (5)-linkedhashmap Source parsing 3. Hash table (hash)Structure Description: If there is a record of the same key and K in the structure, it must be in the storage location of f (k). As a result, the records can be obtained directly without comparison.     The corresponding relationship f is called the hash function, and the table created by this thought is a hash list.     Structure features: High efficiency, fast insertion and deletion, fixed memory, hash conflict. Java collection: HashMap, HashSet, HashTable, Linkedhashmap (linked list + hash table), Linkedhashset (linked list + hash table) Source parsing: Write a comment series to the JDK jdk1.6 container (4)- HashMap source parsing to JDK write Comment series jdk1.6 container (6)-hashset source parsing &map iterator to JDK write Comment series jdk1.6 container (5)-linke Dhashmap Source Code Analysis 4. Heaps (heap)Structure Description: In computer science, a heap is a special tree-shaped data structure that has a value for each node. Usually what we call a heap of data structures is a two fork heap.     The heap is characterized by the minimum (or maximum) value of the root node, and the two subtrees of the root node are also a heap.     Structure features: Insert, delete faster, to the largest items, the smallest item access faster, other items access slower. Java collection: Priorityqueue (priority queue for binary heap implementation) Source parsing: Write a comment series to the JDK jdk1.6 container (x)-priorityqueue source parsing 5. Stacks (Stack)Structure Description: A special linear table that can be inserted and deleted only at one end.     It stores the data in the last-in, first-out principle, the first data is pushed into the bottom of the stack, and the final data is ejected from the top of the stack when it needs to read the data.     Structural features: Advanced back-out (first-in-last-out). Java collection: Stack source parsing: Write a comment series to the JDK jdk1.6 container (Ten)-stack&vector Source code Analysis        6. Queuing (queue)Structure Description: A special linear table that allows for deletion only at the front end of the table (front), and in the back end of the table (rear).     Structural features: FIFO first out. Java collection: Arraydeque (double-ended queue), LinkedList (double-ended queue) source code analysis: to the JDK write annotation Series jdk1.6 container (one)-queue Arraydeque source code parsing to the JDK write comment series jdk1.6 container (2)-linkedlist Source code Analysis
7. Trees (tree)Structure Description: It is a set of hierarchical relationships consisting of n (n>=1) finite nodes.                   (1) Each element is called a node.                   (2) There is a specific node called the root node or roots (root). (3) The remaining data elements outside the root node are divided into M (m≥0) disjoint sets of t1,t2, ...     Tm-1, where each set of Ti (1<=I<=M) itself is also a tree, known as the subtree (subtree) of the original tree.     Structure Features: query, insert, delete are relatively fast, but the algorithm is complex. Java collection: TreeMap (red and Black Tree), TreeSet (red and black tree) source parsing: Write to JDK jdk1.6 container (7)-treemap source parsing to JDK write Comment series jdk1.6 container (8)-treese T&navigablemap&navigableset Source Code Analysis  
Above, we summarize the common data structure and the Java collection of the relationship (of course, the usual data structure and "figure", not here), and briefly introduced the next each data structure of the concept and characteristics. Knowing these conceptual theories, we can give a certain selection guide when we use the Java collection, and henceforth we will never blindly new ArrayList () and new HashMap (), before we use it as much as we would like to use the set.      The use of the process is to insert and delete more or more queries, whether the need to do sorting and so on.           In addition, through the summary will find a secret, of course, you may have discovered, that is, with all the data structures can be implemented with arrays and linked lists, the corresponding ArrayList and LinkedList can also be used as a basis for any data structure. Learning theory is not an end, the concept of summary is not the goal, our slogan is no tooth decay! Amount ~ is the use of knowledge, using theory to guide the practice, the paper came to the end of the preach to know this matter, learning and time to learn the joy ...

Write an annotation to the JDK series of jdk1.6 Containers (13)-Summary of the Java collection and data structure

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.