The linked list set algorithm of the set framework

Yusuke Natsume

Linked list set algorithm:

1. Chain = reference 2. The difference between a linked list set and an array set: In terms of value-added, the speed of an array set is faster than that of the linked list set algorithm [Learn Java, go to Kaige School kaige123.com ]; but the linked list set adds and deletes values. It is more flexible in terms of modifying values ​​and it works like a chain. 3. Classification of linked lists: 3.1 Single-chain collection (just understand): the upper home can find the next home, but the next home cannot find the upper home, that is, the next array can be found through the previous array, but there is no way to pass the next array Find the previous array. As shown below:

image

3.2 Double-chain collection: the upper home can find the next home, and the next home can also find the upper home. As shown below:

image

4. Code implementation (take double chain as an example): 4.1 Add value

image

image

image

image

4.2 Adding values ​​to the header

image

4.3 Adding values ​​to the tail

image

4.4 Delete the first value

image

4.5 Delete the last value

image

4.6 Add value at specified location

imageimage

4.7 Press to delete a value

imageimage

4.8 Improved version of delete operation: when the delete operation is performed, the deleted value can be returned

image

image

image

image

5. Purpose: The linked list collection is mostly used in the queue mode, and tasks are queued in a series of operations. Take the queue mode as an example: the advantage of queuing [Learn Java, go to Kaige School kaige123.com ] is to take out the execution first, as shown in the figure below, you can take the value in the front, enter the value in the back, and of course you can also go out and move forward.

image

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327067143&siteId=291194637