当前位置:网站首页>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.
边栏推荐
- jpa手写sql,用自定义实体类接收
- 力扣今日题-241. 为运算表达式设计优先级
- What is mosaic?
- SWT / anr problem - SWT causes low memory killer (LMK)
- Distance measurement - Hamming distance
- 使用uni-simple-router,动态传参 TypeError: Cannot convert undefined or null to object
- 转行软件测试,知道这四点就够了!
- 使用 pair 做 unordered_map 的键值
- The difference between timer and scheduledthreadpoolexecutor
- 2021 robocom world robot developer competition - preliminary competition of higher vocational group
猜你喜欢

Redis RDB snapshot

How to display real-time 2D map after rviz is opened

ConcurrentSkipListMap——跳表原理

2021 RoboCom 世界机器人开发者大赛-本科组初赛

MySQL binlog cleanup

问题随记 —— /usr/bin/perl is needed by MySQL-server-5.1.73-1.glibc23.x86_64

The essence of software architecture

Huisheng Huiying 2022 intelligent, fast and simple video editing software

TS initial use, TS type

云信小课堂 | IM及音视频中常见的认知误区
随机推荐
[LeetCode] 最后一个单词的长度【58】
sql 优化
神经网络物联网的未来趋势与发展
Three development trends of enterprise application from the perspective of the third technological revolution
2021 RoboCom 世界机器人开发者大赛-高职组初赛
URL introduction
Why is PHP called hypertext preprocessor
Daily three questions 6.30 (2)
认识--Matplotlib
2021 robocom world robot developer competition - semi finals of higher vocational group
Y53. Chapter III kubernetes from introduction to mastery -- ingress (26)
Commemorate becoming the first dayus200 tripartite demo contributor
MT manager test skiing Adventure
Matplotlib常用设置
Huisheng Huiying 2022 intelligent, fast and simple video editing software
Experience of practical learning of Silicon Valley products
Daily three questions 6.30
Stm32f030f4 drives tim1637 nixie tube chip
Zero foundation tutorial of Internet of things development
Redis AOF log