{"id":156113,"date":"2019-09-19T11:46:06","date_gmt":"2019-09-19T03:46:06","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=156113"},"modified":"2019-08-30T09:47:39","modified_gmt":"2019-08-30T01:47:39","slug":"java-hashset-mouth","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/java-hashset-mouth.html","title":{"rendered":"Java\u96c6\u5408 HashSet\u7684\u539f\u7406\u53ca\u5e38\u7528\u65b9\u6cd5"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5bf9\u4e8e HashSet \u800c\u8a00\uff0c\u5b83\u662f\u57fa\u4e8e HashMap \u5b9e\u73b0\u7684\uff0cHashSet \u5e95\u5c42\u4f7f\u7528 HashMap \u6765\u4fdd\u5b58\u6240\u6709\u5143\u7d20\uff0c\u56e0\u6b64 HashSet \u7684\u5b9e\u73b0\u6bd4\u8f83\u7b80\u5355<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4e00. HashSet\u6982\u8ff0<\/strong><\/div>\n

HashSet\u662fJava\u96c6\u5408Set\u7684\u4e00\u4e2a\u5b9e\u73b0\u7c7b\uff0cSet\u662f\u4e00\u4e2a\u63a5\u53e3\uff0c\u5176\u5b9e\u73b0\u7c7b\u9664HashSet\u4e4b\u5916\uff0c\u8fd8\u6709TreeSet\uff0c\u5e76\u7ee7\u627f\u4e86Collection\uff0cHashSet\u96c6\u5408\u5f88\u5e38\u7528\uff0c\u540c\u65f6\u4e5f\u662f\u7a0b\u5e8f\u5458\u9762\u8bd5\u65f6\u7ecf\u5e38\u4f1a\u88ab\u95ee\u5230\u7684\u77e5\u8bc6\u70b9\uff0c\u4e0b\u9762\u662f\u7ed3\u6784\u56fe
\n\"\"<\/p>\n

\r\npublic class HashSet\r\n    extends AbstractSet<\/e>\r\n    implements Set<\/e>, Cloneable, java.io.Serializable\r\n{}\r\n<\/e><\/pre>\n
\u4e8c. HashSet\u6784\u9020<\/strong><\/div>\n

HashSet\u6709\u51e0\u4e2a\u91cd\u8f7d\u7684\u6784\u9020\u65b9\u6cd5\uff0c\u6211\u4eec\u6765\u770b\u4e00\u4e0b<\/p>\n

\r\nprivate transient HashMap map;\r\n\/\/\u9ed8\u8ba4\u6784\u9020\u5668\r\npublic HashSet() {\r\n    map = new HashMap<>();\r\n}\r\n\/\/\u5c06\u4f20\u5165\u7684\u96c6\u5408\u6dfb\u52a0\u5230HashSet\u7684\u6784\u9020\u5668\r\npublic HashSet(Collection< ? extends E> c) {\r\n    map = new HashMap<>(Math.max((int) (c.size()\/.75f) + 1, 16));\r\n    addAll(c);\r\n}\r\n\/\/\u660e\u786e\u521d\u59cb\u5bb9\u91cf\u548c\u88c5\u8f7d\u56e0\u5b50\u7684\u6784\u9020\u5668\r\npublic HashSet(int initialCapacity, float loadFactor) {\r\n    map = new HashMap<>(initialCapacity, loadFactor);\r\n}\r\n\/\/\u4ec5\u660e\u786e\u521d\u59cb\u5bb9\u91cf\u7684\u6784\u9020\u5668\uff08\u88c5\u8f7d\u56e0\u5b50\u9ed8\u8ba40.75\uff09\r\npublic HashSet(int initialCapacity) {\r\n    map = new HashMap<>(initialCapacity);\r\n}\r\n<\/e><\/pre>\n

\u901a\u8fc7\u4e0a\u9762\u7684\u6e90\u7801\uff0c\u6211\u4eec\u53d1\u73b0\u4e86HashSet\u5c31TM\u662f\u4e00\u4e2a\u76ae\u5305\u516c\u53f8\uff0c\u5b83\u5c31\u5bf9\u5916\u63a5\u6d3b\u513f\uff0c\u6d3b\u513f\u63a5\u5230\u4e86\u5c31\u76f4\u63a5\u6254\u7ed9HashMap\u5904\u7406\u4e86\u3002\u56e0\u4e3a\u5e95\u5c42\u662f\u901a\u8fc7HashMap\u5b9e\u73b0\u7684\uff0c\u8fd9\u91cc\u7b80\u5355\u63d0\u4e00\u4e0b:<\/p>\n

HashMap\u7684\u6570\u636e\u5b58\u50a8\u662f\u901a\u8fc7\u6570\u7ec4+\u94fe\u8868\/\u7ea2\u9ed1\u6811\u5b9e\u73b0\u7684\uff0c\u5b58\u50a8\u5927\u6982\u6d41\u7a0b\u662f\u901a\u8fc7hash\u51fd\u6570\u8ba1\u7b97\u5728\u6570\u7ec4\u4e2d\u5b58\u50a8\u7684\u4f4d\u7f6e\uff0c\u5982\u679c\u8be5\u4f4d\u7f6e\u5df2\u7ecf\u6709\u503c\u4e86\uff0c\u5224\u65adkey\u662f\u5426\u76f8\u540c\uff0c\u76f8\u540c\u5219\u8986\u76d6\uff0c\u4e0d\u76f8\u540c\u5219\u653e\u5230\u5143\u7d20\u5bf9\u5e94\u7684\u94fe\u8868\u4e2d\uff0c\u5982\u679c\u94fe\u8868\u957f\u5ea6\u5927\u4e8e8\uff0c\u5c31\u8f6c\u5316\u4e3a\u7ea2\u9ed1\u6811\uff0c\u5982\u679c\u5bb9\u91cf\u4e0d\u591f\uff0c\u5219\u9700\u6269\u5bb9\uff08\u6ce8\uff1a\u8fd9\u53ea\u662f\u5927\u81f4\u6d41\u7a0b\uff09\u3002<\/p>\n

\u5982\u679c\u5bf9HashMap\u539f\u7406\u4e0d\u592a\u6e05\u695a\u7684\u8bdd\uff0c\u53ef\u4ee5\u5148\u53bb\u4e86\u89e3\u4e00\u4e0b<\/p>\n

HashMap\u539f\u7406(\u4e00) \u6982\u5ff5\u548c\u5e95\u5c42\u67b6\u6784<\/p>\n

HashMap\u539f\u7406(\u4e8c) \u6269\u5bb9\u673a\u5236\u53ca\u5b58\u53d6\u539f\u7406<\/p>\n

\u4e09. add\u65b9\u6cd5<\/strong><\/div>\n

HashSet\u7684add\u65b9\u6cd5\u65f6\u901a\u8fc7HashMap\u7684put\u65b9\u6cd5\u5b9e\u73b0\u7684\uff0c\u4e0d\u8fc7HashMap\u662fkey-value\u952e\u503c\u5bf9\uff0c\u800cHashSet\u662f\u96c6\u5408\uff0c\u90a3\u4e48\u662f\u600e\u4e48\u5b58\u50a8\u7684\u5462\uff0c\u6211\u4eec\u770b\u4e00\u4e0b\u6e90\u7801<\/p>\n

\r\nprivate static final Object PRESENT = new Object();\r\n\r\npublic boolean add(E e) {\r\n    return map.put(e, PRESENT)==null;\r\n}\r\n<\/pre>\n

\u770b\u6e90\u7801\u6211\u4eec\u77e5\u9053\uff0cHashSet\u6dfb\u52a0\u7684\u5143\u7d20\u662f\u5b58\u653e\u5728HashMap\u7684key\u4f4d\u7f6e\u4e0a\uff0c\u800cvalue\u53d6\u4e86\u9ed8\u8ba4\u5e38\u91cfPRESENT\uff0c\u662f\u4e00\u4e2a\u7a7a\u5bf9\u8c61\uff0c\u81f3\u4e8emap\u7684put\u65b9\u6cd5\uff0c\u5927\u5bb6\u53ef\u4ee5\u770bHashMap\u539f\u7406(\u4e8c) \u6269\u5bb9\u673a\u5236\u53ca\u5b58\u53d6\u539f\u7406\u3002
\n\"\"<\/p>\n

\u56db. remove\u65b9\u6cd5<\/strong><\/div>\n

HashSet\u7684remove\u65b9\u6cd5\u901a\u8fc7HashMap\u7684remove\u65b9\u6cd5\u6765\u5b9e\u73b0<\/p>\n

\r\n\/\/HashSet\u7684remove\u65b9\u6cd5\r\npublic boolean remove(Object o) {\r\n    return map.remove(o)==PRESENT;\r\n}\r\n\/\/map\u7684remove\u65b9\u6cd5\r\npublic V remove(Object key) {\r\n    Node e;\r\n    \/\/\u901a\u8fc7hash(key)\u627e\u5230\u5143\u7d20\u5728\u6570\u7ec4\u4e2d\u7684\u4f4d\u7f6e\uff0c\u518d\u8c03\u7528removeNode\u65b9\u6cd5\u5220\u9664\r\n    return (e = removeNode(hash(key), key, null, false, true)) == null ? null : e.value;\r\n}\r\n\/**\r\n * \r\n *\/\r\nfinal Node<\/k> removeNode(int hash, Object key, Object value,\r\n                           boolean matchValue, boolean movable) {\r\n    Node<\/k>[] tab; Node<\/k> p; int n, index;\r\n    \/\/\u6b65\u9aa41.\u9700\u8981\u5148\u627e\u5230key\u6240\u5bf9\u5e94Node\u7684\u51c6\u786e\u4f4d\u7f6e\uff0c\u9996\u5148\u901a\u8fc7(n - 1) & hash\u627e\u5230\u6570\u7ec4\u5bf9\u5e94\u4f4d\u7f6e\u4e0a\u7684\u7b2c\u4e00\u4e2anode\r\n    if ((tab = table) != null && (n = tab.length) > 0 &&\r\n        (p = tab[index = (n - 1) & hash]) != null) {\r\n        Node<\/k> node = null, e; K k; V v;\r\n        \/\/1.1 \u5982\u679c\u8fd9\u4e2anode\u521a\u597dkey\u503c\u76f8\u540c\uff0c\u8fd0\u6c14\u597d\uff0c\u627e\u5230\u4e86\r\n        if (p.hash == hash &&\r\n            ((k = p.key) == key || (key != null && key.equals(k))))\r\n            node = p;\r\n        \/**\r\n         * 1.2 \u8fd0\u6c14\u4e0d\u597d\uff0c\u5728\u6570\u7ec4\u4e2d\u627e\u5230\u7684Node\u867d\u7136hash\u76f8\u540c\u4e86\uff0c\u4f46key\u503c\u4e0d\u540c\uff0c\u5f88\u660e\u663e\u4e0d\u5bf9\uff0c \u6211\u4eec\u9700\u8981\u904d\u5386\u7ee7\u7eed\r\n         *     \u5f80\u4e0b\u627e\uff1b\r\n         *\/\r\n        else if ((e = p.next) != null) {\r\n            \/\/1.2.1 \u5982\u679c\u662fTreeNode\u7c7b\u578b\uff0c\u8bf4\u660eHashMap\u5f53\u524d\u662f\u901a\u8fc7\u6570\u7ec4+\u7ea2\u9ed1\u6811\u6765\u5b9e\u73b0\u5b58\u50a8\u7684\uff0c\u904d\u5386\u7ea2\u9ed1\u6811\u627e\u5230\u5bf9\u5e94node\r\n            if (p instanceof TreeNode)\r\n                node = ((TreeNode<\/k>)p).getTreeNode(hash, key);\r\n            else {\r\n                \/\/1.2.2 \u5982\u679c\u662f\u94fe\u8868\uff0c\u904d\u5386\u94fe\u8868\u627e\u5230\u5bf9\u5e94node\r\n                do {\r\n                    if (e.hash == hash &&\r\n                        ((k = e.key) == key ||\r\n                         (key != null && key.equals(k)))) {\r\n                        node = e;\r\n                        break;\r\n                    }\r\n                    p = e;\r\n                } while ((e = e.next) != null);\r\n            }\r\n        }\r\n        \/\/\u901a\u8fc7\u524d\u9762\u7684\u6b65\u9aa41\u627e\u5230\u4e86\u5bf9\u5e94\u7684Node,\u73b0\u5728\u6211\u4eec\u5c31\u9700\u8981\u5220\u9664\u5b83\u4e86\r\n        if (node != null && (!matchValue || (v = node.value) == value ||\r\n                             (value != null && value.equals(v)))) {\r\n            \/**\r\n             * \u5982\u679c\u662fTreeNode\u7c7b\u578b\uff0c\u5220\u9664\u65b9\u6cd5\u662f\u901a\u8fc7\u7ea2\u9ed1\u6811\u8282\u70b9\u5220\u9664\u5b9e\u73b0\u7684\uff0c\u5177\u4f53\u53ef\u4ee5\u53c2\u8003\u3010TreeMap\u539f\u7406\u5b9e\u73b0\r\n             * \u53ca\u5e38\u7528\u65b9\u6cd5\u3011\r\n             *\/\r\n            if (node instanceof TreeNode)\r\n                ((TreeNode<\/k>)node).removeTreeNode(this, tab, movable);\r\n            \/** \r\n             * \u5982\u679c\u662f\u94fe\u8868\u7684\u60c5\u51b5\uff0c\u5f53\u627e\u5230\u7684\u8282\u70b9\u5c31\u662f\u6570\u7ec4hash\u4f4d\u7f6e\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\uff0c\u90a3\u4e48\u8be5\u5143\u7d20\u5220\u9664\u540e\uff0c\u76f4\u63a5\u5c06\u6570\u7ec4\r\n             * \u7b2c\u4e00\u4e2a\u4f4d\u7f6e\u7684\u5f15\u7528\u6307\u5411\u94fe\u8868\u7684\u4e0b\u4e00\u4e2a\u5373\u53ef\r\n             *\/\r\n            else if (node == p)\r\n                tab[index] = node.next;\r\n            \/**\r\n             * \u5982\u679c\u627e\u5230\u7684\u672c\u6765\u5c31\u662f\u94fe\u8868\u4e0a\u7684\u8282\u70b9\uff0c\u4e5f\u7b80\u5355\uff0c\u5c06\u5f85\u5220\u9664\u8282\u70b9\u7684\u4e0a\u4e00\u4e2a\u8282\u70b9\u7684next\u6307\u5411\u5f85\u5220\u9664\u8282\u70b9\u7684\r\n             * next,\u9694\u79bb\u5f00\u5f85\u5220\u9664\u8282\u70b9\u5373\u53ef\r\n             *\/\r\n            else\r\n                p.next = node.next;\r\n            ++modCount;\r\n            --size;\r\n            \/\/\u5220\u9664\u540e\u53ef\u80fd\u5b58\u5728\u5b58\u50a8\u7ed3\u6784\u7684\u8c03\u6574\uff0c\u53ef\u53c2\u8003\u3010LinkedHashMap\u5982\u4f55\u4fdd\u8bc1\u987a\u5e8f\u6027\u3011\u4e2dremove\u65b9\u6cd5\r\n            afterNodeRemoval(node);\r\n            return node;\r\n        }\r\n    }\r\n    return null;\r\n}\r\n<\/k><\/pre>\n

removeTreeNode\u65b9\u6cd5\u5177\u4f53\u5b9e\u73b0\u53ef\u53c2\u8003 TreeMap\u539f\u7406\u5b9e\u73b0\u53ca\u5e38\u7528\u65b9\u6cd5<\/p>\n

afterNodeRemoval\u65b9\u6cd5\u5177\u4f53\u5b9e\u73b0\u53ef\u53c2\u8003LinkedHashMap\u5982\u4f55\u4fdd\u8bc1\u987a\u5e8f\u6027<\/p>\n

\u4e94. \u904d\u5386<\/strong><\/div>\n

HashSet\u4f5c\u4e3a\u96c6\u5408\uff0c\u6709\u591a\u79cd\u904d\u5386\u65b9\u6cd5\uff0c\u5982\u666e\u901afor\u5faa\u73af\uff0c\u589e\u5f3afor\u5faa\u73af\uff0c\u8fed\u4ee3\u5668\uff0c\u6211\u4eec\u901a\u8fc7\u8fed\u4ee3\u5668\u904d\u5386\u6765\u770b\u4e00\u4e0b<\/p>\n

\r\npublic static void main(String[] args) {\r\n    HashSet setString = new HashSet<> ();\r\n    setString.add(\"\u661f\u671f\u4e00\");\r\n    setString.add(\"\u661f\u671f\u4e8c\");\r\n    setString.add(\"\u661f\u671f\u4e09\");\r\n    setString.add(\"\u661f\u671f\u56db\");\r\n    setString.add(\"\u661f\u671f\u4e94\");\r\n\r\n    Iterator it = setString.iterator();\r\n    while (it.hasNext()) {\r\n        System.out.println(it.next());\r\n    }\r\n}\r\n<\/string><\/pre>\n

\u6253\u5370\u51fa\u6765\u7684\u7ed3\u679c\u5982\u4f55\u5462\uff1f
\n\u661f\u671f\u4e8c
\n\u661f\u671f\u4e09
\n\u661f\u671f\u56db
\n\u661f\u671f\u4e94
\n\u661f\u671f\u4e00<\/p>\n

\u610f\u6599\u4e4b\u4e2d\u5427\uff0cHashSet\u662f\u901a\u8fc7HashMap\u6765\u5b9e\u73b0\u7684\uff0cHashMap\u901a\u8fc7hash(key)\u6765\u786e\u5b9a\u5b58\u50a8\u7684\u4f4d\u7f6e\uff0c\u662f\u4e0d\u5177\u5907\u5b58\u50a8\u987a\u5e8f\u6027\u7684\uff0c\u56e0\u6b64HashSet\u904d\u5386\u51fa\u7684\u5143\u7d20\u4e5f\u5e76\u975e\u6309\u7167\u63d2\u5165\u7684\u987a\u5e8f\u3002<\/p>\n

\u516d. \u5408\u8ba1\u5408\u8ba1<\/strong><\/div>\n

\u6309\u7167\u6211\u524d\u9762\u7684\u89c4\u5212\uff0c\u5e94\u8be5\u6bcf\u4e00\u5757\u4e3b\u8981\u7684\u5185\u5bb9\u90fd\u5355\u72ec\u5199\u4e00\u4e0b\uff0c\u5982\u96c6\u5408ArrayList\uff0cLinkedList\uff0cHashMap\uff0cTreeMap\u7b49\u3002\u4e0d\u8fc7\u6211\u5728\u5199\u8fd9\u7bc7\u5173\u4e8eHashSet\u7684\u6587\u7ae0\u65f6\uff0c\u53d1\u73b0\u6709\u524d\u9762\u5bf9HashMap\u7684\u8bb2\u89e3\u540e\uff0c\u786e\u5b9e\u7b80\u5355\uff0cHashSet\u5c31\u662f\u4e00\u4e2a\u76ae\u5305\u516c\u53f8\uff0c\u5728HashMap\u5916\u9762\u52a0\u4e86\u4e00\u4e2a\u58f3\uff0c\u90a3\u4e48LinkedHashSet\u662f\u5426\u5c31\u662f\u5728LinkedHashMap\u5916\u9762\u52a0\u4e86\u4e00\u4e2a\u58f3\u5462\uff0c\u800cTreeSet\u662f\u5426\u662f\u5728TreeMap\u5916\u9762\u52a0\u4e86\u4e00\u4e2a\u58f3\uff1f\u6211\u4eec\u6765\u9a8c\u8bc1\u4e00\u4e0b<\/p>\n

\u5148\u770b\u4e00\u4e0bLinkedHashSet<\/p>\n

\u6700\u5f00\u59cb\u7684\u7ed3\u6784\u56fe\u5df2\u7ecf\u63d0\u5230\u4e86LinkedHashSet\u662fHashSet\u7684\u5b50\u7c7b\uff0c\u6211\u4eec\u6765\u770b\u6e90\u7801<\/p>\n

\r\npublic class LinkedHashSet\r\n    extends HashSet<\/e>\r\n    implements Set<\/e>, Cloneable, java.io.Serializable \r\n{\r\n    \r\n    public LinkedHashSet(int initialCapacity, float loadFactor) {\r\n        super(initialCapacity, loadFactor, true);\r\n    }\r\n\r\n    public LinkedHashSet(int initialCapacity) {\r\n        super(initialCapacity, .75f, true);\r\n    }\r\n\r\n    public LinkedHashSet() {\r\n        super(16, .75f, true);\r\n    }\r\n\r\n    public LinkedHashSet(Collection< ? extends E> c) {\r\n        super(Math.max(2*c.size(), 11), .75f, true);\r\n        addAll(c);\r\n    }\r\n\r\n    public Spliterator<\/e> spliterator() {\r\n        return Spliterators.spliterator(this, Spliterator.DISTINCT | Spliterator.ORDERED);\r\n    }\r\n}\r\n<\/e><\/pre>\n

\u4e0a\u9762\u5c31\u662fLinkedHashSet\u7684\u6240\u6709\u4ee3\u7801\u4e86\uff0c\u662f\u4e0d\u662f\u611f\u89c9\u667a\u5546\u88ab\u5426\u5b9a\u4e86\uff0c\u8fd9\u57fa\u672c\u4e0a\u6ca1\u5565\u4e1c\u897f\u561b\uff0c\u6784\u9020\u5668\u8fd8\u5168\u90e8\u8c03\u7528\u7236\u7c7b\u7684\uff0c\u4e0b\u9762\u5c31\u662f\u5176\u7236\u7c7bHashSet\u7684\u5bf9\u6b64\u7684\u6784\u9020\u65b9\u6cd5<\/p>\n

\r\nHashSet(int initialCapacity, float loadFactor, boolean dummy) {\r\n    map = new LinkedHashMap<>(initialCapacity, loadFactor);\r\n}\r\n<\/pre>\n

\u5927\u5bb6\u4e5f\u770b\u51fa\u6765\uff0c\u548c\u6211\u4eec\u7684\u731c\u6d4b\u4e00\u6837\uff0c\u6ca1\u6709\u6df1\u7a76\u4e0b\u53bb\u7684\u5fc5\u8981\u4e86\u3002\u5982\u679c\u6709\u5174\u8da3\u53ef\u4ee5\u770b\u770bLinkedHashMap\u5982\u4f55\u4fdd\u8bc1\u987a\u5e8f\u6027<\/p>\n

\u5728\u770b\u4e00\u4e0bTreeSet<\/p>\n

\r\npublic class TreeSet extends AbstractSet<\/e>\r\n    implements NavigableSet<\/e>, Cloneable, java.io.Serializable\r\n{\r\n    public TreeSet() {\r\n        this(new TreeMap<\/e>());\r\n    }\r\n    public TreeSet(Comparator< ? super E> comparator) {\r\n        this(new TreeMap<>(comparator));\r\n    }\r\n    public TreeSet(Collection< ? extends E> c) {\r\n        this();\r\n        addAll(c);\r\n    }\r\n    public TreeSet(SortedSet<\/e> s) {\r\n        this(s.comparator());\r\n        addAll(s);\r\n    }\r\n}\r\n<\/e><\/pre>\n

\u786e\u5b9e\u5982\u6211\u4eec\u6240\u731c\u6d4b\uff0cTreeSet\u4e5f\u5b8c\u5168\u4f9d\u8d56\u4e8eTreeMap\u6765\u5b9e\u73b0\uff0c\u5982\u679c\u6709\u5174\u8da3\u53ef\u4ee5\u770b\u770bTreeMap\u539f\u7406\u5b9e\u73b0\u53ca\u5e38\u7528\u65b9\u6cd5<\/p>\n

\u4e03. \u603b\u7ed3<\/strong><\/div>\n

\u672c\u6765\u60f3\u4e09\u7ae0\u7684\u5185\u5bb9\uff0c\u4e00\u7ae0\u5c31\u7b97\u5b8c\u4e86\uff0c\u867d\u7136Set\u5b9e\u73b0\u6709\u70b9\u8d56\u76ae\uff0c\u6bd5\u7adf\u4ed6\u7956\u8f88\u662fCollection\u800c\u4e0d\u662fMap\uff0c\u5728Map\u7684\u5b9e\u73b0\u7c7b\u4e0a\u7a7f\u4e86\u4e00\u5c42\u8863\u670d\u5c31\u6210\u4e86Set\uff0c\u7136\u540e\u51fa\u4e8e\u67d0\u79cd\u76ee\u7684\u57cb\u4f0f\u5728Collection\u4e2d\uff0c\u54c8\u54c8\uff0c\u5f00\u4e2a\u73a9\u7b11\uff0c\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u4e86HashSet\u7684\u539f\u7406\u4ee5\u53ca\u4e3b\u8981\u65b9\u6cd5\uff0c\u540c\u65f6\u7b80\u5355\u4ecb\u7ecd\u4e86LinkedHashSet\u548cTreeSet\uff0c\u82e5\u6709\u4e0d\u5bf9\u4e4b\u5904\uff0c\u8bf7\u6279\u8bc4\u6307\u6b63\uff0c\u671b\u5171\u540c\u8fdb\u6b65\uff0c\u8c22\u8c22\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

HashSet\u662fJava\u96c6\u5408Set\u7684\u4e00\u4e2a\u5b9e\u73b0\u7c7b\uff0cSet\u662f\u4e00\u4e2a\u63a5\u53e3\uff0c\u5176\u5b9e\u73b0\u7c7b\u9664HashSet\u4e4b\u5916\uff0c\u8fd8\u6709TreeS […]<\/p>\n","protected":false},"author":63,"featured_media":156116,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-156113","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/156113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=156113"}],"version-history":[{"count":9,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/156113\/revisions"}],"predecessor-version":[{"id":157577,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/156113\/revisions\/157577"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/156116"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=156113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=156113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=156113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}