GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update Java集合.md · trialbox/Java-Interview@cc74682

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Java集合.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Java集合.md‎

Copy file name to clipboard
+12-4Lines changed: 12 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
说出所有java集合类
2-
一.HashMap
1+
2+
# 一.HashMap
33
https://blog.csdn.net/jiary5201314/article/details/51439982
4-
(1)hashMap的原理
4+
## 1.hashMap的原理
55
hashmap 是数组和链表的结合体,数组每个元素存的是链表的头结点 往 hashmap
66
里面放键值对的时候先得到 key 的 hashcode,然后重新计算 hashcode, (让 1 分布均匀因为如果分布不均匀,低位全是 0,则后来计算数组下标的时候会 冲突),然后与 length-1 按位与,计算数组出数组下标 如果该下标对应的链表为空,则直接把键值对作为链表头结点,如果不为空,则 遍历链表看是否有 key 值相同的,有就把 value 替换, 没有就把该对象最为链表的第 一个节点,原有的节点最为他的后续节点
7-
2.hashcode的计算
7+
## 2.hashcode的计算
88
https://www.zhihu.com/question/20733617/answer/111577937
99
https://blog.csdn.net/justloveyou_/article/details/62893086
1010
Key.hashcode是key的自带的hascode函数是一个int值32位
11+
12+
hashmap jdk1.8 中 hashmap 重计算 hashcode 方法改动: 高 16 位异或低 16 位
13+
>return (key == null) ? 0 : h = key.hashCode() ^ (h >>> 16);
14+
首先确认:当 length 总是 2 的n 次方时, h & (length - 1) 等价于 hash 对length 取模 , 但是&比%具有更高的效率;
15+
>Jdk1.7 之前:h & (length - 1);//第三步,取模运算
16+
17+
18+

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.