Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01451b1

Browse files
committed
学习 hash
1 parent 6e9c16c commit 01451b1

File tree

9 files changed

+61
-11
lines changed

9 files changed

+61
-11
lines changed

‎README.zh-CN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,4 @@ npm test -- 'playground'
310310
- https://coolshell.cn/articles/4671.html
311311
- https://www.cs.usfca.edu/~galles/visualization/Algorithms.html
312312
- https://www.cs.usfca.edu/~galles/visualization/source.html
313+
- [常用数据结构对比及其应用场景](https://www.jianshu.com/p/ec17d738327f)

‎examples/README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ https://bost.ocks.org/mike/
2727
Java程序员3面小米,被俩算法题难倒,微软员工6分钟解决,真丢脸
2828
https://zhuanlan.zhihu.com/p/38850888
2929

30+
各种算法题等
31+
https://blog.csdn.net/v_JULY_v
32+
3033

3134
为什么算法这么难? https://zhuanlan.zhihu.com/p/25101438
3235

‎examples/hash/README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ HASH 主要用于信息安全领域中加密算法,它把一些不同长度的
3232
- [MD5](https://baike.baidu.com/item/MD5)
3333
- [SHA家族](https://baike.baidu.com/item/SHA%E5%AE%B6%E6%97%8F/9849595)
3434
- [npm: md5](https://www.npmjs.com/package/md5)
35+
- [常见hash算法的原理](http://www.cnblogs.com/zhoug2020/p/6984191.html)
36+
- [转 从头到尾彻底解析Hash表算法](https://www.cnblogs.com/dancheblog/p/3512284.html)
37+
- [Hash 函数的常用算法和应用领域](http://www.cnblogs.com/qianxun/archive/2011/07/03/2096773.html)

‎examples/uuid/README.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,26 @@ GUID(Globals Unique Identifiers 全局统一标识符)是微软对UUID这个
1111

1212
世界上的任何两台计算机都不会生成重复的 GUID 值。GUID 主要用于在拥有多个节点、多台计算机的网络或系统中,分配必须具有唯一性的标识符。在 Windows 平台上,GUID 应用非常广泛:注册表、类及接口标识、数据库、甚至自动生成的机器名、目录名等。一个GUID可以在后台数据库中操作一个主键。
1313

14+
## 适用于分布式唯一标识码的生成算法有哪些?
15+
16+
- 利用数据库生成
17+
- 利用Redis/MongoDB/zookeeper生成
18+
- UUID
19+
- UUID有基于MAC地址的,加上时间和时钟序列的,也有基于伪随机数的,基于加密哈希的。
20+
- Twitter的snowflake算法
21+
- Twitter开源,基于zk,41位时间戳(毫秒数)+10位机器的ID+12位毫秒内的流水号+1位符号位(永远是0)。
22+
- 优点:性能不错,单机内递增。
23+
- 缺点:依赖zk;依赖于机器时钟,分布式环境内可能会不是全局递增。
24+
- 百度 UidGenerator
25+
- UidGenerator是百度开源的分布式ID生成器,基于于snowflake算法的实现,看起来感觉还行。不过,国内开源的项目维护性真是担忧。
26+
- 美团 Leaf
27+
- Leaf 是美团开源的分布式ID生成器,能保证全局唯一性、趋势递增、单调递增、信息安全,里面也提到了几种分布式方案的对比,但也需要依赖关系数据库、Zookeeper等中间件。
28+
1429
参考资料:
1530

1631
- https://blog.csdn.net/forlong401/article/details/7580147
1732
- https://blog.csdn.net/yuanlianming663/article/details/1842267
1833
- https://www.cnblogs.com/pangguoming/p/7090906.html
1934
- http://www.cnblogs.com/snandy/p/3261754.html
35+
- https://m.zjurl.cn/answer/6640244087003808014/?iid=59688834959
36+
- https://tech.meituan.com/2017/04/21/mt-leaf.html

‎src/data-structures/hash-table/README.zh-CN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ end Hash
5656

5757
- [Wikipedia](https://en.wikipedia.org/wiki/Hash_table)
5858
- [YouTube](https://www.youtube.com/watch?v=shs0KM3wKv8&index=4&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
59+
- [LinkedHashMap、HashMap比较](https://www.jianshu.com/p/979bc680b79f)

‎src/data-structures/linked-list/LinkedList.js‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,6 @@ export default class LinkedList {
234234
return nodes;
235235
}
236236

237-
/**
238-
* @param {*[]} values - Array of values that need to be converted to linked list.
239-
* @return {LinkedList}
240-
*/
241-
fromArray(values) {
242-
values.forEach(value => this.append(value));
243-
244-
return this;
245-
}
246-
247237
/**
248238
* @param {function} [callback]
249239
* @return {string}

‎src/data-structures/linked-list/README.zh-CN.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ end ReverseTraversal
163163
| :-------: | :-------: | :-------: | :-------: |
164164
| O(n) | O(n) | O(1) | O(1) |
165165

166+
这里删除的时间复杂度怎么会是 O(1) 呢,这里明明需要遍历,应该是O(n)
167+
168+
如果已知需要删除的**节点**,那么可以使用以下方法优化到 O(1)
169+
170+
参考:https://mp.weixin.qq.com/s/4Tg_NsXS8Z4DQPBIxwJplg
171+
166172
### 空间复杂度
167173

168174
O(n)

‎src/data-types/index.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/* eslint no-var: 0, no-unused-vars: 0, prefer-const: 0 */
32
// number
43
var nine = 9;

‎ts/data-types/index.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
/* eslint no-var: 0, no-unused-vars: 0, prefer-const: 0 */
3+
4+
// number
5+
var nine = 9;
6+
7+
const three: number = 3;
8+
let two: number = 2;
9+
10+
// boolean
11+
const bool: boolean = false;
12+
13+
// 命名名称必须有效,改为如下
14+
const decThree: number = 3;
15+
let decTwo: number = 2;
16+
let testa: number = 2;
17+
18+
// boolean
19+
let isDone: boolean = false;
20+
21+
// string
22+
const city: string = 'shanghai';
23+
24+
// null
25+
let nul: null = null;
26+
27+
// undefined
28+
let empty;
29+
30+
// let bigInter = 23142314231412345663451234n;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /