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 ...
随机推荐
- 【卷二】网络三—UDP服务器与客户端
这是另一个类型的服务器/客户端,无连接的 UDP: (User Datagram Protocol) 用户数据报协议 参考: P58~P60 UDP 时间戳服务器 [时间戳 就是ctime()显示的内 ...
- 在eclipse中maven web项目部署到tomcat,访问不了
修改eclipse中tomcat发布路径后,能正常访问
- [译][待续]Chap1.Using neural nets to recognize handwritten digits
Chapter1 使用神经网络辨识手写数字 人类的视觉系统是自然界的一大奇迹.试看如下的手写数列: 绝大多数人都能毫不费劲地认出这些数字是504192,而这会让人产生识别数字非常简单的错觉.人类大脑的 ...
- 初学laravel框架,解决访问路由404的问题
运行环境:windows+phpstorm+Nginx 第一步:添加 PHP Built-in Web Server 第二步:配置路径和端口(路径是你的laravel中的pubilc,端口是你没有占用 ...
- foreach 循环的应用传值
$arr=array(1,5,8,8,9);foreach ($arr as $key => $value) { //这里可以一边改外面$arr的值一边下一步循环 $value=++$value ...
- webAppRootKey
web.xml中webAppRootKey ------------------------------------------------------------------------------ ...
- ansible尝试
1.下载软件 http://releases.ansible.com/ansible/ 2.软件安装 [root@Yangjian-VM02-241 ansible-stable-2.0.0.1]# ...
- [bash] 查找替换文件
写这个脚本也加深了对 bash 数组的理解. #!/bin/bash #2015-11-23 echo -e "说明:\n将文件放在/app/tmp_class目录下,保证该目录下没有其他文 ...
- ES 集群调整、升级 最佳实践
日常应用中我们会经常对es 集群做一些参数调整或者升级版本,但是每次关闭节点再打开 其中的数据同步的痛苦估计有很多人领悟过(有可能出现IO或者网络拥堵导致恶性循环)官网有套方案可以尝试一下: 1.关掉 ...
- 微信小程序官方demo学习
最近微信小程序很火,很喜欢那种轻应用,用完就走的理念.于是,下载好微信开发者工具,学习一下官方demo. 体验下来,有类似react和vue的感觉,dom类似react那种组件的,data-bindi ...