当前位置:网站首页>Map的实现类的顺序性
Map的实现类的顺序性
2022-07-03 08:06:00 【小朋友哈哈】
Map的实现类有:LinkedHashMap,TreeMap,HashMap
LinkedHashMap:记录添加顺序的有序性。继承自HashMap,比HashMap增加了双链表,节点中增加了前后指针,LinkedHashMap中增加了head,tail指针
TreeMap:默认升序,红黑树
HashMap:无序 ,数组+链表+红黑树
// LinkedHashMap按照插入的顺序输出结果
Map<Character,Integer> map = new LinkedHashMap<>();
map.put('c',2);
map.put('a',4);
map.put('g',3);
map.put('d',1);
// {c=2, a=4, g=3, d=1}// TreeMap按照key顺序输出结果
Map<Character,Integer> map = new TreeMap<>();
map.put('c',2);
map.put('a',4);
map.put('g',3);
map.put('d',1);
// {a=4, c=2, d=1, g=3}// HashMap 无序
Map<Character,Integer> map = new HashMap<>();
map.put('c',2);
map.put('a',4);
map.put('g',3);
map.put('d',1);
// {a=4, c=2, d=1, g=3}边栏推荐
猜你喜欢

Worldview satellite remote sensing image data / meter resolution remote sensing image

Are you still watching the weather forecast on TV?

A tunnel to all ports of the server
![[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)](/img/de/1c75b5e7ed79aca47462de365428a7.jpg)
[set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)

CLion-Toolchains are not configured Configure Disable profile问题解决

Unity change default editor

About the problem that the editor and the white screen of the login interface cannot be found after the location of unityhub is changed

MAE

Pycharm remote ssh pyenv error: pydev debugger: warning: trying to add breakpoint to file that does
![[set theory] order relation (the relation between elements of partial order set | comparable | strictly less than | covering | Haas diagram)](/img/df/a034032e203e7935dafaf8a71cb6c8.jpg)
[set theory] order relation (the relation between elements of partial order set | comparable | strictly less than | covering | Haas diagram)
随机推荐
Maxcompute string splitting function -split_ PART
jsutlis
regular expression
Pulitzer Prize in the field of information graphics - malofiej Award
Shader foundation 01
Zohocrm deluge function application time verification
Golang json格式和结构体相互转换
Flex flexible box layout
How does yarn link help developers debug NPM packages?
Puhua PLM empowers the whole scene product lifecycle management and helps the enterprise digital transformation of the main line of products
Oracle queries grouped by time
P2622 关灯问题II(状态压缩 搜索)
Usage of (case, when) in PostgreSQL
The difference between hdmi2.1 and hdmi2.0 and the conversion of PD signals.
Basic operation and process control 2
C#课程设计之员工信息管理系统
MAE
What is a data type? What is the use of data types?
Unity one click AssetBundle
什麼是定義?什麼是聲明?它們有何區別?