list, set, and map are the three most important interfaces in this set system. Where list and set inherit from the collection interface. Set does not allow elements to be duplicated. HashSet and TreeSet are the two main implementation classes. The list is ordered and allows elements to be duplicated. ArrayList, LinkedList, and vectors are the three main implementation classes. The map also belongs to the collection system, but differs from the collection interface. A map is a collection of key pairs of value, where the key column is a collection. Key cannot be duplicated, but value can be repeated. HashMap, TreeMap, and Hashtable are the three main implementation classes. The SortedSet and SortedMap interfaces sort the elements by the specified rules, sortedmap the key column. Vectors and hashtable are thread-synchronized (synchronized). In performance, ArrayList and HashMap are better than vectors and Hashtable, respectively.
| Collection |
Performance |
Default Capacity |
space-Time size |
overhead of 10K entries |
set the size exactly? |
extension Algorithm |
HashSet |
o (1) |
16 | TD style= "Border-top-color: #cccccc; PADDING:8PX 5px; Vertical-align:top; Background-color: #f7f8fa; " >144
|
|
X2 |
HashMap |
o (1) |
16 |
128 |
360k |
no |
x2 |
Hashtable |
o (1) |
11 | TD style= "Border-top-color: #cccccc; PADDING:8PX 5px; Vertical-align:top; Background-color: #f7f8fa; " >104
|
|
X2+1 |
LinkedList | TD style= "Border-top-color: #cccccc; PADDING:8PX 5px; Vertical-align:top; " >o (n)
1 |
48 |
240k |
is |
+1 |
ArrayList |
o (n) |
10 | TD style= "Border-top-color: #cccccc; PADDING:8PX 5px; Vertical-align:top; Background-color: #f7f8fa; " >88
|
|
x1.5 |
StringBuffer |
O (1) |
16 |
72 |
24 |
Whether |
X2
|
UML Empty Arrows solid lines are inherited, empty arrows dashed lines are implemented
From for notes (Wiz)
Java collection classes