HashSet
HashSet
1 | public class HashSet<E> |
This class implements the Set interface, backed by a hash table (actually a HashMap instance).
Note that this implementation is not synchronized.Set s = Collections.synchronizedSet(new HashSet(...));
Abstract
主要实现依赖于HashMap
1 | public class HashSet<E> |
… …
Set
Note: Great care must be exercised if mutable objects are used as set elements.(will modify the value in Set, just like clone–浅拷贝)
… …
***the hashcode of entry in HashMap:table is unmutable, it is fixed when create entry, so add a mutable entry, and then you can change it(Particularly, you can make it be same with others, but its place(or hash) in table is fixed just like before.).When resize the Map, the hashcode will not change. ***
-------------再接再厉更进一步---------------