"Silly Bird See JDK1.7 collection of source code" Java collection overall framework

Source: Internet
Author: User

First of all, this is just my notes, there may be errors, if you can enter the crossing discernment please feel free to point out, I will accept ~ ~

The main reference is the Great God's blog http://blog.csdn.net/column/details/collection.html

  The Java Collection Toolkit, located under the Util package, contains a number of common data structures, such as arrays, lists, stacks, queues, collections, hash tables, and so on. The Learning Collection framework can be broadly divided into five parts: list lists, set sets, map mappings, iterators (Iterator, enumeration), tool classes (Arrays, collections).

Here is the frame diagram:

   It can be seen from the top layer is 3 interfaces, respectively, is the iterator iterator Super interface, this interface does not implement any interface, is the top layer. And the collection interface is the implementation of the iterator interface, there is a dependency relationship, map according to JDK1.7 Source can see is also a super interface, no interface method implemented. Specific Analysis:(1)Collection Interface is a highly abstracted interface, the internal elements allow ordering can also be unordered, depending on the need to implement its methods, the most common specific direct ports such as: List and Set,deque, and the implementation of the class vectorA list interface , which represents lists, such as arrays, queues, linked lists, stacks, and so on, where elements can be duplicated, common implementations such as ArrayList and LinkedList, a list of array implementations, and a list of lists implemented using linked lists, all of which allow repeating elements to be added, The following specific analysis usage;The set interface , which represents a collection where the elements are not allowed to be duplicated, are commonly used by the implementation classes: HashSet and Treeset,hashset are implemented through the HashMap in the map, and TreeSet is implemented through the TREEMAP in the map. One of the TreeSet also implements a SortedSet interface, so the interior is orderly; Deque Interface , indicating the queue;The vector class is an array of vectors that can be used to grow an array of objects, usually implemented as stack stacks, advanced and out; Note: We can see that abstract classes Abstractcollection, Abstractlist, and Abstractset respectively implement the collection, list, and set interfaces, which are many of the adapter design patterns used in the Java Collection framework. Using these abstract classes to implement interfaces, implement some or all of the interfaces in an abstract class so that some of the following classes only need to inherit the abstract class, and implement their own required methods, without implementing all the abstract methods in the interface. The main function of this adapter design pattern is that we now need to implement a function in the interface, but do not want to implement its full functionality, we can transition in the middle of an abstract implementation class to help us first implement the entire method of this interface, then we directly inherit the abstract class, The override is then overridden by the method implemented in this abstract class. This is the essence of the adapter design pattern ... (2) map is a mapping interface, where each element is a Key-value key value pair, the same abstract class Abstractmap through the adapter mode to achieve the map interface of most functions, TREEMAP, HashMap and so on is through inheriting this abstract class to implement the map interface;the elements in the map are unique, the key value is calculated by hashcode, cannot be duplicated, value can be repeated, TreeMap implements SortedMap so is ordered, HashMap is unordered.  (3) The iterator interface is an iterator interface that is used primarily to iterate through the elements in the collection, but cannot traverse the map collection and only traverse the implementation class of the collection interface.  (4) The Arrays and collections tool classes are the two tool classes used to manipulate arrays and collections.

"Silly Bird See JDK1.7 collection of source code" Java collection overall framework

Related Article

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.