当前位置:网站首页>Day_ seventeen
Day_ seventeen
2022-06-25 16:26:00 【grp_ grp_ grp】
1. LinkedList
Basic use

Introduce
LinkedList : The bottom layer is a two-way linked list , Because it's not continuous storage
It's just that you can find the address of the next element , Therefore, adding and deleting operations are efficient
But the query efficiency is low , Because you can only find one by one from the first
Use

1.1 Underlying implementation
LinkedList : The bottom layer is a two-way linked list , A linked list consists of nodes , Because it's a two-way list , So there are three attributes in the node
1 Saved data Object
2 Next node object Node type
3 Previous node object Node type

1.1.2 obtain
get Method
Simulate how subscripts are obtained , It is essentially a traversal operation


2. set
Set characteristic Disordered and unrepeatable , Unordered means that the order of addition and extraction are not guaranteed to be the same
classification :
HashSet : At the bottom is a hash table
TreeSet : At the bottom are red and black trees , The added elements must be sorted according to a certain format
( Numbers : Default from small to large , character string : Per person ASCII Code to sort , date : Natural date , Yesterday today tomorrow )
Be careful :
Use TreeSet When , The element must implement Comparable Interface , Because when adding , This interface will be called automatically compareTo Methods for comparison
Add string , Numbers , When it comes to dates , Automatically sort , Because Integer,String,Date Both implement the interface and the method
If we want to store custom types , You need to let this class implement the corresponding interfaces and methods to store
2.1 TreeSet


3. Sort
Use TreeSet When , The element must implement Comparable Interface , Because when adding , This interface will be called automatically compareTo Methods for comparison
Add string , Numbers , When it comes to dates , Automatically sort , Because Integer,String,Date Both implement the interface and the method
If we want to store custom types , You need to let this class implement the corresponding interfaces and methods to store
3.1 compareble and comparator
Comparator It is also a comparator class Comparable It's also for comparison , If these two exist at the same time , be Comparator High priority
usage :
Comparable : If treeSet When saving our own defined types in , Use Comparable
Comparator : If treeSet When the type we write is not saved in , Then use Comparator To specify the collation
such as Integer The default is ascending sort , If we need to sort in descending order , We can only use Comparator, Because we can't change Integer Source code
But this time Integer There is Comparable The implementation of the interface , Equal to two comparisons exist , however Comparator High priority
So it will be sorted according to the rules we define

3.2 List Sort

边栏推荐
- Bugly hot update usage
- Summary of 2022 spring moves of ordinary people (Alibaba and Tencent offer)
- Day_ fourteen
- In the wechat environment, H5 jumps to the specified page of the applet
- Alvaria announces Jeff cotten, a veteran of the customer experience industry, as its new CEO
- flutter
- Dino: Detr with improved detecting anchor boxes for end to end object detection
- Linux-MySQL数据库之高级SQL 语句一
- 一文带你搞懂 JWT 常见概念 & 优缺点
- 一行代码可以做什么?
猜你喜欢

深入理解和把握数字经济的基本特征

The style of the mall can also change a lot. DIY can learn about it!

The first day of reading mysql45

Don't underestimate the integral mall, its role can be great!

Swift responsive programming

GO语言-锁操作
Power representation in go language

Navicat premium 15 for MAC (database development tool) Chinese version

Coredata data persistence

Reading mysql45 lecture - index continued
随机推荐
炮打司令部,别让一个UI框架把你毁了
The paid video at station B caused the up master to lose more than ten thousand fans
Day_ eleven
Go language - lock operation
What processes are needed to build a wechat applet from scratch?
一文带你搞懂 JWT 常见概念 & 优缺点
Xinlou: un voyage de sept ans de Huawei Sports Health
Day_ ten
商城风格也可以很多变,DIY了解一下!
_ 17 collection overview
Problems caused by using ApplicationContext to render layout
Uniapp converts graphic verification codes in the form of file streams into images
flutter
解析数仓lazyagg查询重写优化
Uncover gaussdb (for redis): comprehensive comparison of CODIS
XML usage and parsing of data storage and transmission files
八种button的hover效果
What can NFT metauniverse development do?
Native JS dynamically add elements
Message format of Modbus (PLC)