Comments (1)
- 不使用 property 也可以,不过每次就需要调用函数来返回。
- 对的,这里
__contains__
实现可以使用 in 操作。 - index 是可以不一样的,目前hash 函数其实适合 hash table 长度有关。
- 搬迁的过程就是把之前所有有元素的值搬过去,新的 hash 表里得到的下标已经不是原来的值了,被删除的元素就不用考虑了,你直接算B 的hash得到下标的槽就可以找到 b。
- 可以看下 siphash 的实现,如果你感兴趣可以看下 cpython 里或者 redis hash 的实现。真正的实现还是很复杂的,要考虑不同的数据类型的。
参考:
- https://www.laurentluce.com/posts/python-dictionary-implementation/
- https://stackoverflow.com/questions/2070276/where-can-i-find-source-or-algorithm-of-pythons-hash-function
from python_data_structures_and_algorithms.
Related Issues (20)
- priority queue优先级相同的元素 HOT 2
- btree.py里面的preorder_trav_use_stack HOT 1
- 关于Hash的问题 HOT 1
- HashTable里的_find_key() 是有bug,还是我理解有问题 HOT 1
- 关于链表remove 时间复制度问题 HOT 1
- hashtable中的key和value没有解释明白 HOT 1
- 视频能否考虑开源啊? HOT 1
- 你好,关于循环双向链表的remove方法的一些疑问 HOT 2
- 关于您python-web-guide仓库的一个问题 HOT 1
- 堆与堆排序的问题 HOT 1
- 循环双端列表链表append问题
- 单测问题 HOT 2
- linked_list.py的remove方法貌似有误 HOT 1
- 你好,剑指offer33题目的标题和内容不匹配哈,标题是最小数,代码是最大数 HOT 1
- gitbook勘误 HOT 2
- leetcode实战 HOT 1
- 哈希表的二次探测函数有bug,会出现无限循环
- array 可以装别的 class吗? 自定义的class
- 课时6find方法为什么不能和remove那样呢
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python_data_structures_and_algorithms.