Java – underlying datastructure of HashSet

For ArrayList, the basic datastructure is array. For LinkedList, it is a link object. For HashMap or hashtable, it can be an array of LinkedList or tree. What is the data structure used in HashSet

Solution

According to the Javadoc, the backup data structure of HashSet is HashMap

The JDK 1.6 code verifies this:

public HashSet() {
    map = new HashMap<>();
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>