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的更多相关文章

  1. [C++]Linux之头文件sys/types.h[/usr/include/sys]

    1.查找<sys/types.h>文件 一般地,Linux的C头文件<sys/types.h>路径在如题的途径:/usr/include/sys下,然而博主[Linux For ...

  2. Linux queue.h之TAILQ队列分析

    转自 这两天想看看memcached的实现,所以先学习了libevent,使用起来还是比较简单的,其实是对select/poll/kqueue等的封装,学习libevent过程中又遇到了linux下队 ...

  3. sys/types.h fcntl.h unistd.h sys/stat.h

    sys/types.h 是Unix/Linux系统的基本系统数据类型的头文件,含有size_t,time_t,pid_t等类型. 在应用程序源文件中包含 <sys/types.h> 以访问 ...

  4. /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 ...

  5. [百科]sys/types.h

    sys/types.h中文名称为基本系统数据类型.在应用程序源文件中包含 <sys/types.h> 以访问 _LP64 和 _ILP32 的定义.此头文件还包含适当时应使用的多个基本派生 ...

  6. #include <sys/stat.h>的作用

    #include <sys/stat.h> 文件状态, 是unix/linux系统定义文件状态所在的伪标准头文件. 含有类型与函数: dev_t     st_dev     Device ...

  7. sys/time.h 和 time.h

    今天在燕麦工作第二天.看荣哥给我的程序,发现程序里面用的延时跟我以前使用的不同.导入两个头文件,然后用函数来获得时间.关于这个函数特别查来一下. time.h  是ISO C99 标准日期头文件. s ...

  8. #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使用详解(精髓) ...

  9. [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 ...

随机推荐

  1. ContourLine

    #define MULTI_PLOT true //Determine whether or not to plot multiple iterations. #define X_MAX 1.0 // ...

  2. sql优化--in和exists效率

    系统要求进行SQL优化,对效率比较低的SQL进行优化,使其运行效率更高,其中要求对SQL中的部分in/not in修改为exists/not exists 修改方法如下: in的SQL语句 SELEC ...

  3. NOIP2010-普及组初赛C语言解析

    第十六届全国青少年信息学奥林匹克联赛初赛试题 一.单项选择题 (共20题,每题1.5分,共计30分.每题有且仅有一个正确选项.) 1.2E+03表示(  D  ). A.2.03          B ...

  4. C#第十天

    1.c#中的访问修饰符 public :公开的公共的 private:私有的,只能在当前类的内部访问 protected:受保护的,只能在当前类的内部以及该类的子类中访问. internal:只能在当 ...

  5. HDU 4262 Juggler

    点我看题 初步想法是模拟,找到下一个位置并记录操作数,O(n^2)肯定会超时. 那么进行优化,会发现到下一位置的操作数就是两个位置之间存在的数的个数,于是就变成了计数问题. 不难想到用树状数组或线段树 ...

  6. jquery复选框操作

    $('input[type="checkbox"]').change(function(e) { var checked = $(this).prop("checked& ...

  7. HDU 5860 Death Sequence(递推)

    HDU 5860 Death Sequence(递推) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=5860 Description You ...

  8. some links

    rename user: http://www.cyberciti.biz/faq/howto-change-rename-user-name-id/

  9. Hibernate之环境搭建

    开始之前,我想先理清一个概念,即ORM是什么? ORM介绍 全称:Object/Relation Mapping,即对象/关系映射. ORM也可以理解为一种规范,具体的ORM框架可作为应用程序和数据库 ...

  10. 兼容 console 没删除引起 低级浏览器 报错问题

    /*重写connsole.log,防止调试代码出错*/if (!window.console){ var names = ["log", "debug", &q ...