当前位置:网站首页>Concurrentskiplistmap -- principle of table skipping
Concurrentskiplistmap -- principle of table skipping
2022-07-01 23:35:00 【HD243608836】
In order to elicit ConcurrentSkipListMap, First, let's briefly understand what is skip table .
For single chain table , Even if the linked list is ordered , If you want to find some data in it , You can only traverse the linked list from beginning to end , In this way, the efficiency will be very low , The jump watch is different . Jump table is a kind of data structure that can be used to find quickly , It's kind of like a balance tree . They can all find elements quickly . But an important difference is : The insertion and deletion of the balance tree may lead to a global adjustment of the balance tree ; And the insertion and deletion of the jump table , You only need to operate on parts of the entire data structure . The advantage of this is : In the case of high concurrency , Need a global lock , To ensure the thread safety of the whole balance tree ; And for jump tables , Then only part of the lock is needed . such , In a highly concurrent environment , You can have better performance . In terms of query performance , The time complexity of the jump table is O(logn), So in concurrent data structures ,JDK Use a jump table to implement a Map.
Essence of skip table , yes Multiple linked lists are maintained at the same time , And linked lists are hierarchical :

The lowest linked list , All elements in the jump table are maintained , Each layer of linked list , Are subsets of the lower layer .
All the elements of the linked list in the jump list are sorted . When looking for , You can start with the top-level list . Once it is found that the element being searched is larger than the value in the current linked list , Will go to the next level of linked list to continue looking for . That is to say, during the search process , The search is leaping . As shown in the figure above , Look up elements in the jump table 18.

lookup 18 When , Originally, you need to traverse 18 Time , Now it's just a matter of 7 Next time . When the length of the linked list is relatively large , Build index , The improvement of search efficiency will be very obvious .
It's easy to see from above , Jump table is an algorithm that uses space to change time .
Use the jump table to achieve Map, And using hash algorithm to achieve Map The other difference between them is : Hashing doesn't hold the order of the elements , And all the elements in the jump table are sorted . therefore , When traversing the jump table , You'll get an orderly result . therefore , If your application needs order , So watch jumping is your best choice .
JDK The class that implements this data structure in is ConcurrentSkipListMap
.
边栏推荐
- Applet form verification encapsulation
- Matplotlib常用设置
- 在代码中使用SqlCommand对象
- [understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing
- Redis数据类型和应用场景
- Postgresql随手记(10)动态执行EXECUTING语法解析过程
- 2022 examination questions and online simulation examination for safety management personnel of hazardous chemical business units
- Daily three questions 6.29
- 第六章 数据流建模
- 每日三题 6.30
猜你喜欢
Matplotlib common charts
神经网络物联网的未来趋势与发展
有没有一段代码,让你为人类的智慧所折服
notBlank 和 notEmpty
[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing
Notes to problems - file /usr/share/mysql/charsets/readme from install of mysql-server-5.1.73-1 glibc23.x86_ 64 c
[must] bm41 output the right view of the binary tree [medium +]
Paramètres communs de matplotlib
纪念成为首个DAYUs200三方demo贡献者
2021 RoboCom 世界机器人开发者大赛-高职组初赛
随机推荐
De PIP. Interne. CLI. Main Import main modulenotfounderror: No module named 'PIP'
Behind sharing e-commerce: the spirit of CO creation, symbiosis, sharing, CO prosperity and win-win
Chapter 6 data flow modeling
[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing
Reproduction process and problems of analog transformer (ICLR 2022 Spotlight)
2022 safety officer-c certificate examination question simulation examination question bank and simulation examination
Redis RDB snapshot
物联网现状及未来发展趋势
使用uni-simple-router,动态传参 TypeError: Cannot convert undefined or null to object
PostgreSQL source code (57) why is the performance gap so large in hot update?
Matplotlib常用图表
Redis master-slave synchronization
写给当前及未来博士研究生一些建议整理分享
from pip._internal.cli.main import main ModuleNotFoundError: No module named ‘pip‘
Daily three questions 6.30 (2)
2022-07-01:某公司年会上,大家要玩一食发奖金游戏,一共有n个员工, 每个员工都有建设积分和捣乱积分, 他们需要排成一队,在队伍最前面的一定是老板
每日三题 6.30(2)
PostgreSQL source code (58) tuple splicing heap_ form_ Tuple analysis
2021 robocom world robot developer competition - preliminary competition of undergraduate group
Matplotlib common charts