Java Container Induction

Source: Internet
Author: User

Collection:
|--subinterface
|--set
|--Sortset
|--TreeSet
The interior is actually a TreeMap object.
Compared by the CompareTo method.
Relatively large in left, small on right side.
|--HashSet
The internal real HashMap or Linkedhashmap,add method actually calls the map's put
No duplicate objects: you need to override the Hashcode and Equals methods.
Disordered
Allow NULL to be deposited
Out of sync

|--list
|--ArrayList
The actual inside is the array
New ArrayList () creates an empty array. The Add method initializes the size when the default value is 10.
If the storage is full, expand, expand by formula: Raw capacity + raw capacity >>1;

|--linklist
Inside is the node object first,last.

Add calls the Linklast method, and if last is empty, both last and first are the object.

The Add method is as follows:

Final node<e> L = last; Final node<e> NewNode = new node<> (l, E, NULL); last = NewNode; if (L = = null) First   = NewNode; else   l.next = NewNode; size++; modcount++;



|--Vector
The inner object is an array of objects. When the Add method is called, the size is initialized, and the default value is 10.
After the storage is full, the expansion, if the number of incoming expansion, the number of capacity expansion, if not passed, the original capacity to expand.
The Add method is synchronous.

Map
Subclass of |--hashmap:abstractmap
HashMap is actually a one-Map.entry implementation class node object. That is, HashMap is actually an array of node. The default size is 16, with a default threshold of 12,
When the number of elements in the HashMap exceeds 12, the expansion is carried out each time.
The Put method is non-synchronous, allowing null keys and null values.
When put, the method's Hashcode method is called and the Equals method is used to compare the keys.
The Get method is non-synchronous.
The Get method is called GetNode and then compares the object's hashcode and values (equals), if present, to return.

|--linkedhashmap

Subclass of |--hashtalbe:dictionary
Hashtable is actually an implementation class entry object of a map.entry. That is, Hashtable is actually an array of entry. The default size is 11, with a default threshold of 8.
When the number of elements in the Hashtable exceeds 8, the capacity is expanded to *2+1 each time. The critical value is the capacity of the. 75f times.
The Put method is synchronous and does not allow NULL keys and null values.
The Put method invokes the hashcode of the object and the Equals method for the key comparison.
The Get method is synchronous.
The Get method invokes the object's hashcode and equals to compare the value of the key, if present, to return.
|--sortedmap

|--treemap


Above is some of their own summary, welcome the great God to correct, add! ~

Java Container Induction

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.