Question about two-way linked list-Self-Summary

Source: Internet
Author: User

Keywords: two-way linked list

In fact, it is relatively simple for experienced people to look down.


In the driver, insert all the disks found to the end of the two-way linked list (listhead), and then upload the nodes that meet the conditions to another linked list (disks. By default, the first node in listhead must meet the conditions and be inserted to the end of disks. After this action is completed, the link in the listhead changes when the second node is obtained. It looks strange.

List_entry listhead; list_entry disks; struct disk_info {list_entry entry ;...}... plistentry = listhead. flink; diskinfo = containing_record (plistentry, disk_info, entry); inserttaillist (& disks, & diskinfo-> entry); // (1) While (...) {plistentry = plistentry-> flink; // (2) In fact, at this time, plistentry-> flink does not match diskinfo0 = containing_record (plistentry, disk_info, entry );}


The discerning person may understand at first glance that at (1), the plistentry is linked to disks, so its flink has also changed, and it is no longer listhead. flink-> flink. In fact, this is equivalent to breaking a node from linked list 1 (not completely) and putting it in linked list 2. Its next node is definitely not the next node in the original linked list 1.


The expression capability is gradually improving...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.