Learning BSD.sys/queue.h
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. and that is the difference between List & TailQueue.
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:

List is used in places need to insert and delete everywhere frequently, but without quick addition/removement at tail ( because no pointer in the head struct pointing to the tail, and that's why it cannot be backward-traversed).
S(inglyLinked)list is used in places need to insert and delete from head frequently, it maynot be inserted/deleted from middle/tail.
S(inglyLinked)tailqueue is used in places need to insert after any element, delete head or any named element(O(n)), get the last element, insert after the last item quickly, this datastruct accelerates things to be done at the tail.
S(imple)queue is ued in places which is identically as S(inglyLinked)tailqueue..
Tailqueue is used to insert at head/tail quickly, before/after any element, delete any given item(O(1)). Traverse in either direction.
CircleQueue is used to insert/delete anywhere, insert/delete head/tail items are quicklier, tail & head are linked as previous/post element one another.
Learning BSD.sys/queue.h的更多相关文章
- [C++]Linux之头文件sys/types.h[/usr/include/sys]
1.查找<sys/types.h>文件 一般地,Linux的C头文件<sys/types.h>路径在如题的途径:/usr/include/sys下,然而博主[Linux For ...
- Linux queue.h之TAILQ队列分析
转自 这两天想看看memcached的实现,所以先学习了libevent,使用起来还是比较简单的,其实是对select/poll/kqueue等的封装,学习libevent过程中又遇到了linux下队 ...
- sys/types.h fcntl.h unistd.h sys/stat.h
sys/types.h 是Unix/Linux系统的基本系统数据类型的头文件,含有size_t,time_t,pid_t等类型. 在应用程序源文件中包含 <sys/types.h> 以访问 ...
- /usr/include/sys/types.h:62: error: conflicting types for ‘dev_t’
/usr/include/sys/types.h:62: error: conflicting types for ‘dev_t’/usr/include/linux/types.h:13: erro ...
- [百科]sys/types.h
sys/types.h中文名称为基本系统数据类型.在应用程序源文件中包含 <sys/types.h> 以访问 _LP64 和 _ILP32 的定义.此头文件还包含适当时应使用的多个基本派生 ...
- #include <sys/stat.h>的作用
#include <sys/stat.h> 文件状态, 是unix/linux系统定义文件状态所在的伪标准头文件. 含有类型与函数: dev_t st_dev Device ...
- sys/time.h 和 time.h
今天在燕麦工作第二天.看荣哥给我的程序,发现程序里面用的延时跟我以前使用的不同.导入两个头文件,然后用函数来获得时间.关于这个函数特别查来一下. time.h 是ISO C99 标准日期头文件. s ...
- #include <sys/epoll.h> epoll - I/O event notification facility 服务器端 epoll(7) - Linux manual page http://www.man7.org/linux/man-pages/man7/epoll.7.html
epoll使用详解(精髓) - Boblim - 博客园 https://www.cnblogs.com/fnlingnzb-learner/p/5835573.html epoll使用详解(精髓) ...
- [opencv3.2cmake error ] sys/videoio.h no such file or directories
I don't have /usr/include/sys/videoio.h at all Before that , I have ipp download question. So I down ...
随机推荐
- NET 2.0(C#)调用ffmpeg处理视频的方法
另外:ffmpeg的net封装库 http://www.intuitive.sk/fflib/ NET 2.0 调用FFMPEG,并异步读取输出信息的代码...public void ConvertV ...
- 微信小程序 textarea 简易解决方案
微信小程序中textarea没有bindchange事件,所以无法在输入时给变量赋值. 虽然可以使用bindblur事件,但是绑定bindblur事件,如果再点击按钮,则先执行完按钮事件后,再去执行b ...
- 使用inno setup制作安装包
- 【转】CSS
css概念 http://www.cnblogs.com/moveofgod/archive/2012/09/18/2691101.html css八大功能 http://developer.51ct ...
- iOS 加载本地 HTML 文件 CSS 样式图片无效果
在开发的过程中,有时候需要加载一些 HTML 页面,对于不太复杂的界面,基本上都可以放到本地用 UIWebview 来加载,但是在开发过程中会碰到 UIWebview 加载出来的 HTML 页面没有图 ...
- openvpn环境搭建
以下为服务端.客户端下载安装包,在CentOS 6.5部署,也可以找到相关下载源 openvpn-2.2.2.tar.gz,openvpn-2.1.3-install.rar,(https://git ...
- Python笔记5(字符串)-20160921
一.字符串常用方法 1.title():返回字符串的标题版本,即单词首字母大写其余字母小写 2.upper():返回字符串全部大写版本,lower()则返回字符串全部小写版本 >>> ...
- 使用SQL Server视图的优缺点
SQL Server视图我们经常会用的到,下面就为您介绍使用SQL Server视图的优缺点,希望可以对您SQL Server视图有更多的了解. 在程序设计的时候必须先了解视图的优缺点,这样可以扬长避 ...
- 小谈数据库Char、VarChar、NVarChar差异
1. char 固定长度,最长n个字符. 2. varchar 最大长度为n的可变字符串. (n为某一整数,不同数据库,最大长度n不同) char和varchar区别: ...
- Spire.XLS 在程序中直接打印excel
上代码 if (tbPrintSetBindingSource.Current == null) return; var item_TbPrintSet = tbPrintSetBindingSour ...