码迷,mamicode.com
首页 > 其他好文 > 详细

Learning BSD.sys/queue.h

时间:2016-09-09 18:41:11      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

This file includes 4 data-structures..

Insteresting because they are written in 1994.. to make it easier using the structures..

LIST:

技术分享

the common usage of the structures is to create a structure containing the list-entry as manage-tools of its pointers, this structure might contain prev|next pointers.

Then to create a header of the specific data-structure.. this header contains only 1 pointer pointing to the first struct of the data-structure..

then the pointed struct‘s next pointer is pointing to the next struct of the list, or null, the prev pointer is pointing to the previous pointer‘s address.

so this kind of design has its problem: cannot know if it‘s the first struct of this structure, even do not know if it has a prev pointer.. and actually cannot traverse backward..

As i forseen, this kind of design can back-traverse, but in other way like using methods like container_of(le_prev,type). though no macros in queue.h can do this. As the document says, it‘s a list may only be traversed in forward direction.

this doubly linked list has its fast insertion in the middle of the list, if buildt a hash table for all the **prev address and their entries. O(1).

the usages:

技术分享

 

Learning BSD.sys/queue.h

标签:

原文地址:http://www.cnblogs.com/sansna/p/5857448.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!