https://github.com/leinlin/sortedlistdictionary
https://github.com/leinlin/sortedlistdictionary
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/leinlin/sortedlistdictionary
- Owner: leinlin
- Created: 2022-10-24T09:53:33.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-10-26T07:34:49.000Z (over 3 years ago)
- Last Synced: 2025-02-28T16:40:49.350Z (over 1 year ago)
- Language: C#
- Size: 6.84 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SortedListDictionary
## 速度对比:
- 哈希表的插入、删除、查找的时间复杂度都是 O(1);
- 而二分查找字典的查找的时间复杂度都是 O(logn),插入和删除为O(n+logn)
## 哈希表速度快,但缺点明显,被反杀:
- hash表内存占用一般是实际数据数量的3倍左右,如果是配置表这种数据量大的结构可以考虑用这种方式进行内存压缩
- 内存中排列有序,foreach遍历的时候顺序能够得到保证,不依赖hashcode算法,帧同步游戏不会出现不同步的问题
- 扩容速度快,直接用SIMD内存复制
- 不存在rehash操作,查询性能稳定在 O(logn)
- 二分表中插入数据不是第一时间进行排序,而是再插入大量数据后进行一次性排序
结论对性能要求不是特别高,内存需要压缩的客户端游戏配置可以考虑。