Sign in
Sign up
Explore
Enterprise
Education
Search
Help
Terms of use
About Us
Explore
Enterprise
Education
Gitee Premium
Gitee AI
AI teammates
Sign in
Sign up
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Cancel
Sign in
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
Watch
Unwatch
Watching
Releases Only
Ignoring
3
Star
47
Fork
23
DreamCoders
/
CoderGuide
Code
Issues
1169
Pull Requests
0
Wiki
Insights
Pipelines
Service
JavaDoc
PHPDoc
Quality Analysis
Jenkins for Gitee
Tencent CloudBase
Tencent Cloud Serverless
悬镜安全
Aliyun SAE
Codeblitz
SBOM
DevLens
Don’t show this again
Update failed. Please try again later!
Remove this flag
Content Risk Flag
This task is identified by
as the content contains sensitive information such as code security bugs, privacy leaks, etc., so it is only accessible to contributors of this repository.
Java中集合框架底层数据结构
Backlog
#IAJKQF
陌生人
owner
Opened this issue
2024-08-13 10:04
<p><span style="color: rgb(51, 51, 51);">Collection </span></p><h4><span style="color: rgb(51, 51, 51);">List </span></h4><p><span style="color: rgb(51, 51, 51);">Arraylist</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">:</span><span style="color: rgb(51, 51, 51);"> Object</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">数组 </span></p><p><span style="color: rgb(51, 51, 51);">Vector</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">:</span><span style="color: rgb(51, 51, 51);"> Object</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">数组 </span></p><p><span style="color: rgb(51, 51, 51);">LinkedList</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">: 双向循环链表</span><span style="color: rgb(51, 51, 51);"> </span></p><h4><span style="color: rgb(51, 51, 51);">Set </span></h4><p><span style="color: rgb(51, 51, 51);">HashSet</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">(无序,唯一):基于</span><span style="color: rgb(51, 51, 51);"> HashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">实现的,底层采用</span><span style="color: rgb(51, 51, 51);"> HashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">来保存元素 </span></p><p><span style="color: rgb(51, 51, 51);">LinkedHashSet</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">:</span><span style="color: rgb(51, 51, 51);"> LinkedHashSet </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">继承与</span><span style="color: rgb(51, 51, 51);"> HashSet</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">,并且其内部是通过</span><span style="color: rgb(51, 51, 51);"> LinkedHashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">来实现的。有点类似于我们之前说的</span><span style="color: rgb(51, 51, 51);">LinkedHashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">其内部是基 于</span><span style="color: rgb(51, 51, 51);"> Hashmap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">实现一样,不过还是有一点点区别的。 </span></p><p><span style="color: rgb(51, 51, 51);">TreeSet</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">(有序,唯一): 红黑树</span><span style="color: rgb(51, 51, 51);">(</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">自平衡的排序二叉树。</span><span style="color: rgb(51, 51, 51);">) Map </span></p><p><span style="color: rgb(51, 51, 51);">HashMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">:</span><span style="color: rgb(51, 51, 51);"> JDK1.8</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">之前</span><span style="color: rgb(51, 51, 51);">HashMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">由数组</span><span style="color: rgb(51, 51, 51);">+</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">链表组成的,数组是</span><span style="color: rgb(51, 51, 51);">HashMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">的主 体,链表则是主要为了解决哈希冲突而存在的(</span><span style="color: rgb(51, 51, 51);">“</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">拉链法</span><span style="color: rgb(51, 51, 51);">”</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">解决冲突)</span><span style="color: rgb(51, 51, 51);">.JDK1.8</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">以后在解决哈希冲突时有了较大的变化,当链表长度大于阈值(默认为</span><span style="color: rgb(51, 51, 51);">8</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">)时,将链表转 化为红黑树,以减少搜索时间 </span></p><p><span style="color: rgb(51, 51, 51);">LinkedHashMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">:</span><span style="color: rgb(51, 51, 51);">LinkedHashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">继承自</span><span style="color: rgb(51, 51, 51);"> HashMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">,所以它的底层仍然是 基于拉链式散列结构即由数组和链表或红黑树组成。另外,</span><span style="color: rgb(51, 51, 51);">LinkedHashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">在上面 结构的基础上,增加了一条双向链表,使得上面的结构可以保持键值对的插入顺序。 同时通过对链表进行相应的操作,实现了访问顺序相关逻辑。 </span></p><p><span style="color: rgb(51, 51, 51);">HashTable</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">: 数组</span><span style="color: rgb(51, 51, 51);">+</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">链表组成的,数组是</span><span style="color: rgb(51, 51, 51);"> HashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">的主体,链表则是主要为 了解决哈希冲突而存在的 </span></p><p><span style="color: rgb(51, 51, 51);">TreeMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">: 红黑树(自平衡的排序二叉树) </span></p>
<p><span style="color: rgb(51, 51, 51);">Collection </span></p><h4><span style="color: rgb(51, 51, 51);">List </span></h4><p><span style="color: rgb(51, 51, 51);">Arraylist</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">:</span><span style="color: rgb(51, 51, 51);"> Object</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">数组 </span></p><p><span style="color: rgb(51, 51, 51);">Vector</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">:</span><span style="color: rgb(51, 51, 51);"> Object</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">数组 </span></p><p><span style="color: rgb(51, 51, 51);">LinkedList</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">: 双向循环链表</span><span style="color: rgb(51, 51, 51);"> </span></p><h4><span style="color: rgb(51, 51, 51);">Set </span></h4><p><span style="color: rgb(51, 51, 51);">HashSet</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">(无序,唯一):基于</span><span style="color: rgb(51, 51, 51);"> HashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">实现的,底层采用</span><span style="color: rgb(51, 51, 51);"> HashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">来保存元素 </span></p><p><span style="color: rgb(51, 51, 51);">LinkedHashSet</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">:</span><span style="color: rgb(51, 51, 51);"> LinkedHashSet </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">继承与</span><span style="color: rgb(51, 51, 51);"> HashSet</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">,并且其内部是通过</span><span style="color: rgb(51, 51, 51);"> LinkedHashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">来实现的。有点类似于我们之前说的</span><span style="color: rgb(51, 51, 51);">LinkedHashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">其内部是基 于</span><span style="color: rgb(51, 51, 51);"> Hashmap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">实现一样,不过还是有一点点区别的。 </span></p><p><span style="color: rgb(51, 51, 51);">TreeSet</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">(有序,唯一): 红黑树</span><span style="color: rgb(51, 51, 51);">(</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">自平衡的排序二叉树。</span><span style="color: rgb(51, 51, 51);">) Map </span></p><p><span style="color: rgb(51, 51, 51);">HashMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">:</span><span style="color: rgb(51, 51, 51);"> JDK1.8</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">之前</span><span style="color: rgb(51, 51, 51);">HashMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">由数组</span><span style="color: rgb(51, 51, 51);">+</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">链表组成的,数组是</span><span style="color: rgb(51, 51, 51);">HashMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">的主 体,链表则是主要为了解决哈希冲突而存在的(</span><span style="color: rgb(51, 51, 51);">“</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">拉链法</span><span style="color: rgb(51, 51, 51);">”</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">解决冲突)</span><span style="color: rgb(51, 51, 51);">.JDK1.8</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">以后在解决哈希冲突时有了较大的变化,当链表长度大于阈值(默认为</span><span style="color: rgb(51, 51, 51);">8</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">)时,将链表转 化为红黑树,以减少搜索时间 </span></p><p><span style="color: rgb(51, 51, 51);">LinkedHashMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">:</span><span style="color: rgb(51, 51, 51);">LinkedHashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">继承自</span><span style="color: rgb(51, 51, 51);"> HashMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">,所以它的底层仍然是 基于拉链式散列结构即由数组和链表或红黑树组成。另外,</span><span style="color: rgb(51, 51, 51);">LinkedHashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">在上面 结构的基础上,增加了一条双向链表,使得上面的结构可以保持键值对的插入顺序。 同时通过对链表进行相应的操作,实现了访问顺序相关逻辑。 </span></p><p><span style="color: rgb(51, 51, 51);">HashTable</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">: 数组</span><span style="color: rgb(51, 51, 51);">+</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">链表组成的,数组是</span><span style="color: rgb(51, 51, 51);"> HashMap </span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">的主体,链表则是主要为 了解决哈希冲突而存在的 </span></p><p><span style="color: rgb(51, 51, 51);">TreeMap</span><span style="color: rgb(51, 51, 51); font-family: 微软雅黑;">: 红黑树(自平衡的排序二叉树) </span></p>
Comments (
0
)
Sign in
to comment
Status
Backlog
Backlog
Doing
Done
Closed
Assignees
Not set
Labels
Java
Not set
Label settings
Milestones
No related milestones
No related milestones
Pull Requests
None yet
None yet
Successfully merging a pull request will close this issue.
Branches
No related branch
Branches (
-
)
Tags (
-
)
Planed to start   -   Planed to end
-
Top level
Not Top
Top Level: High
Top Level: Medium
Top Level: Low
Priority
Not specified
Serious
Main
Secondary
Unimportant
参与者(1)
1
https://gitee.com/DreamCoders/CoderGuide.git
git@gitee.com:DreamCoders/CoderGuide.git
DreamCoders
CoderGuide
CoderGuide
Going to Help Center
Search
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register